Part Number Hot Search : 
AD515AJ MC1741CP DP8876 01205 S8599 S00DC13 S8599 S8599
Product Description
Full Text Search
 

To Download VRS51L2070 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  VRS51L2070 preliminary datasheet rev 1.2 ramtron international corporation ? http://www.ramtron.com 1850 ramtron drive colorado springs ? mcu customer service: 1-800-943-4625, 1-514-871-2447 x 208 colorado, usa, 80921 ? 1-800-545-fram, 1-719-481-7000 page 1 of 99 high-performance versa 8051 mcu overview the VRS51L2070 is a high performance, 8051-based microcontroller coupled with a fully integrated array of peripherals for addressing a broad range of embedded design applications. based on a powerful 40-mips, single-cycle, 8051 microprocessor, the VRS51L2070?s memory sub-system features 64kb of flash and 4352 bytes of sram. support peripherals include a hardware based arithmetic unit capable of performing complex mathematical operations, jtag interface used for flash programming and non-intrusive in-circuit debugging/emulation, a precision inte rnal oscillator (2% accuracy) and a watchdog timer. communication and control of external devices is facilitated via an assortment of digital peripherals such as an enhanced, fully configurable spi bus, an i2c interface, dual uarts with dedicated baud rate generators, 8 pwm contro llers, 3 16-bit timers and 2 pulse width counter modules. the VRS51L2070 is powered by a 3.3 volt supply, can function over the industrial temperatur e range, and is available in a qfp-64 package (see vrs51l2170 datasheet for plcc/qfp-44 packages - pin compatible with the industry standard 8051 microcontroller footprint/pin-out). f igure 1: VRS51L2070 f unctional d iagram VRS51L2070 8051 core single cycle 40mhz mult/accu/div w/ 32-bit barrel shifter interrupt controller pwms/ timers (8) watch dog timer power-on/ reset flash 64k bytes uarts, baud rate generators (2) on-board oscillator sram 4352 bytes jtag w/on-chip emulation pulse width counters (2) ports (7), i/os (56) timer capture inputs (3) crystal oscillator inputs dynamic clock control spi i 2 c external data bus controller feature set o 8051 high performance single cycle processor (operation up to 40 mips) o 64kb flash program memory (in-system/ln-application programmable) o 4352 bytes of sram (4kb + 256) (ext. 4k bytes can be used for program or data memory) o jtag interface for flash programming and non-intrusive debugging/in-circuit emulation o mult/div/accu unit including barrel shifter o 56 general purpose i/os (64-pin version) o 2 serial uarts/2 baud rate generators (16-bit) o enhanced spi interface (fully configurable word size) o fully configurable i 2 c interface (master/slave) o 16 external interrupt pins/interrupt on port pin change o 16-bit general purpose timer/counters o 3 timer capture inputs o 2 pulse width counter modules o 8 pwm controller outputs with individual timers o pwms can be used as g eneral purpose timers o precision internal oscillator o dynamic system clock frequency adjustment o power saving features o power-on reset/brown-out detect o watchdog timer o operating voltage: 3.1v to 3.6v o operating temperature -40c to +85c f igure 2: VRS51L2070 qfp-64 p in out d iagrams 17 32 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 VRS51L2070 qfp-64 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 sdo-p1.5 sck-scl*-pc1.3-p1.6 sdi-sda*-p1.7 reset rxd0-pc0.1-p3.0 t0out-p4.5 pwm0*-p5.0 pwm1*-p5.1 pwm2*-p5.2 pwm3*-p5.3 vss txd0-p3.1 int0-pc0.0-p3.2 int1-pc1.0-p3.3 t0in-scl-exbr0-pc0.3-p3.4 t1in-sda-exbr1-p3.5 p0.2-ad2 p0.3-ad3 p0.1-ad1 p0.0-ad0 p6.4-a4 p6.3-a3 p6.2-a2 p6.1-a1-t2in* p6.0-a0-t2ex* vdd p4.4-t2out p1.0-cs0-t2in p1.1-cs1-t2ex p1.2-cs2-pc1.1-rxd1-t2out* p1.3-cs3-txd1 p1.4-ss-t1out* wr-p3.6 vdd rd-p3.7 pwm4*-p5.4 pwm5*-p5.5 pwm6*-p5.6 pwm7*-p5.7 xtal1-p4.6 xtal2-p4.7 vss t1out-p4.0 pwm0-a8-p2.0 pwm1-a9-p2.1 pwm2-a10-p2.2 txd0*-pwm3-a11-p2.3 rxd0*-pwm4-a112-p2.4 p0.4-ad4 p0.5-ad5 p0.6-ad6 p0.7-ad7 p6.5-a5 p6.6-a6 p6.7-a7 pc1.2-t0ex-rxd1* t1ex-txd1* p4.3-tdi p4.2-td0 cm0-ale p4.1-tms p2.7-a15-pwm7-tck p2.6-a14-pwm6-t0ex p2.5-a13-pwm5-t1ex
VRS51L2070 ________________________________________________________________________________________________ www.ramtron.com page 2 of 99 pin descriptio ns for qfp-64 t able 1: VRS51L2070 p in d escriptions for qfp-64 package qfp - 64 name i/o function p1.5 i/o port 1.5 1 sdo o spi data output p1.6 i/o port 1.6 sck o spi clock scl* i/o i2c clock (alternate pin) 2 pc1.3 i pulse counter pc1 input 3 p1.7 i/o port p1.7 sdi i spi data input 3 sda* i/o i2c data (alternate pin) 4 reset i/o reset p3.0 i/o port 3.0 rxd0 i uart0 rx pin 5 pc0.1 i pulse counter pc0 input 1 p4.5 i/o port 4.5 6 t0out o timer 0 output p5.0 i/o port 5.0 7 pwm0* o pwm0 output (alternate pin) p5.1 i/o port 5.1 8 pwm1* o pwm1 output (alternate pin) p5.2 i/o port 5.2 9 pwm2* o pwm2 output (alternate pin) p5.3 i/o port 5.3 10 pwm3* o pwm3 output (alternate pin) 11 vss gnd device ground p3.1 i/o port 3.1 12 txd0 o uart0 tx pin p3.2 i/o port 3.2 int0 i interrupt 0 input 13 pc0.0 pulse counter pc0 input 0 p3.3 i/o port 3.3 int1 i interrupt 1 input 14 pc1.0 pulse counter pc1 input 0 p3.4 i/o port 3.4 scl i/o i2c clock t0in i timer 0 input pc0.3 i pulse counter pc0 input 3 15 exbr0 i uart0 external baud rate input p3.5 i/o port 3.5 sda i/o i2c data t1in i timer 1 input 16 exbr1 i uart1 external baud rate input p3.6 i/o port 3.6 17 wr o ext data memory access write signal (active low) p3.7 i/o port 3.7 18 rd o ext data memory access read signal (active low) 19 vdd vdd positive supply p5.4 port 5.4 20 pwm4* o pwm4 output (alternate pin) p5.5 port 5.5 21 pwm5* o pwm5 output (alternate pin) p5.6 port 5.6 22 pwm6* o pwm6 output (alternate pin) p5.7 port 5.7 23 pwm7* o pwm7 output (alternate pin) qfp - 64 name i/o function xtal1 o crystal oscillator (output) 24 p4.6 i/o port 4.6 xtal2 i crystal oscillator (input) 25 p4.7 i/o port 4.7 26 vss gnd device ground p4.0 i/o port 4.0 27 t1out o timer 1 output p2.0 i/o port 2.0 pwm0 o pwm0 output 28 a8 o ext. address bus a8 p2.1 i/o port 2.1 pwm1 o pwm1 output 29 a9 o ext. address bus a9 p2.2 i/o port 2.2 pwm2 o pwm2 output 30 a10 o ext. address bus a10 p2.3 i/o port 2.3 pwm3 o pwm3 output txd0* o uart0 tx pin (alternate pin ) 31 a11 o ext. address bus a11 p2.4 i/o port 2.4 pwm4 o pwm4 output rxd0* i uart0 rx pin (alternate pin) pc0.2 i pulse counter pc0 input 2 32 a12 o ext. address bus a12 p2.5 i/o port 2.5 pwm5 o pwm5 output t1ex i timer 1 ex input 33 a13 o ext. address bus a13 p2.6 i/o port 2.6 pwm6 o pwm6 output t0ex i timer 0 ex input 34 a14 o ext. address bus a114 p2.7 i/o port 2.7 pwm7 o pwm7 output tck i jtag tck input 35 a15 o ext. address bus a15 p4.1 i/o port 4.1 36 tms i jtag tms input cm0 i jtag program mode 37 ale o ext address latch enable p4.2 i/o port 4.2 38 tdo o jtag tdo line p4.3 i/o port 4.3 39 tdi i jtag tdi line txd1* o uart1 tx pin (alternate pin) 40 t1ex i timer 1 ex input rxd1* i uart1 rx pin (alternate pin) t0ex i timer 0 ex input 41 pc1.2 i pulse counter pc1 input 2 p6.7 i/o port 6.7 42 a7 o ext. address 7 (non-multiplexed mode) p6.6 i/o port 6.6 43 a6 o ext. address 6 (non-multiplexed mode) p6.5 i/o port 6.5 44 a5 o ext. address 5 (non-multiplexed mode)
VRS51L2070 ________________________________________________________________________________________________ www.ramtron.com page 3 of 99 qfp - 64 name i/o function p0.7 i/o port 0.7 45 ad7 i/o ext. address/data bus ad7 p0.6 i/o port 0.6 46 ad6 i/o ext. address/data bus ad6 p0.5 i/o port 0.5 47 ad5 i/o ext. address/data bus ad5 p0.4 i/o port 0.4 48 ad4 i/o ext. address/data bus ad4 p0.3 i/o port 0.3 49 ad3 i/o ext. address/data bus ad3 p0.2 i/o port 0.2 50 ad2 i/o ext. address/data bus ad2 p0.1 i/o port 0.1 51 ad1 i/o ext. address/data bus ad1 p0.0 i/o port 0.0 52 ad0 i/o ext. address/data bus ad0 p6.4 i/o port 6.4 53 a4 o ext. address 4 (non-multiplexed mode) p6.3 i/o port 6.3 54 a3 o ext. address 3 (non-multiplexed mode) p6.2 i/o port 6.2 55 a2 o ext. address 2 (non-multiplexed mode) p6.1 i/o port 6.1 a1 o ext. address 1 (non-multiplexed mode) 56 t2in* i timer 2 input (alternate) p6.0 i/o port 6.0 a0 o ext. address 0 (non-multiplexed mode) 57 t2ex* i timer 2 ex input (alternate) 58 vdd positive supply p4.4 i/o port 4.4 59 t2out o timer 2 output p1.0 i/o port 1.0 cs0 o spi chip select 0 60 t2in i timer 2 input p1.1 i/o port 1.1 cs1 o spi chip select 1 61 t2ex i timer 2 ex input p1.2 i/o port 1.2 cs2 o spi chip select 2 rxd1 i uart1 rx line pc1.1 i pulse counter pc1 input 1 62 t2out o timer 2 output pin (alternate pin) p1.3 i/o port 1.3 cs3 o spi chip select 3 63 txd1 o uart1 tx line p1.4 i/o port 1.4 ss i spi slave select input 64 t1out* o timer 1 output (alternate pin) 17 32 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 VRS51L2070 qfp-64 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 sdo-p1.5 sck-scl*-pc1.3-p1.6 sdi-sda*-p1.7 reset rxd0-pc0.1-p3.0 t0out-p4.5 pwm0*-p5.0 pwm1*-p5.1 pwm2*-p5.2 pwm3*-p5.3 vss txd0-p3.1 int0-pc0.0-p3.2 int1-pc1.0-p3.3 t0in-scl-exbr0-pc0.3-p3.4 t1in-sda-exbr1-p3.5 p0.2-ad2 p0.3-ad3 p0.1-ad1 p0.0-ad0 p6.4-a4 p6.3-a3 p6.2-a2 p6.1-a1-t2in* p6.0-a0-t2ex* vdd p4.4-t2out p1.0-cs0-t2in p1.1-cs1-t2ex p1.2-cs2-pc1.1-rxd1-t2out* p1.3-cs3-txd1 p1.4-ss-t1out* wr-p3.6 vdd rd-p3.7 pwm4*-p5.4 pwm5*-p5.5 pwm6*-p5.6 pwm7*-p5.7 xtal1-p4.6 xtal2-p4.7 vss t1out-p4.0 pwm0-a8-p2.0 pwm1-a9-p2.1 pwm2-a10-p2.2 txd0*-pwm3-a11-p2.3 rxd0*-pwm4-a112-p2.4 p0.4-ad4 p0.5-ad5 p0.6-ad6 p0.7-ad7 p6.5-a5 p6.6-a6 p6.7-a7 pc1.2-t0ex-rxd1* t1ex-txd1* p4.3-tdi p4.2-td0 cm0-ale p4.1-tms p2.7-a15-pwm7-tck p2.6-a14-pwm6-t0ex p2.5-a13-pwm5-t1ex
VRS51L2070 ___________________ __________________ _______________ ______________ _______________ _______________ www.ramtron.com page 4 of 99 f igure 3: l arger v iew of VRS51L2070 qfp-64 p ackage pinout 17 32 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 VRS51L2070 qfp-64 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 sdo-p1.5 sck-scl*-pc1.3-p1.6 sdi-sda*-p1.7 reset rxd0-pc0.1-p3.0 t0out-p4.5 pwm0*-p5.0 pwm1*-p5.1 pwm2*-p5.2 pwm3*-p5.3 vss txd0-p3.1 int0-pc0.0-p3.2 int1-pc1.0-p3.3 t0in-scl-exbr0-pc0.3-p3.4 t1in-sda-exbr1-p3.5 p0.2-ad2 p0.3-ad3 p0.1-ad1 p0.0-ad0 p6.4-a4 p6.3-a3 p6.2-a2 p6.1-a1-t2in* p6.0-a0-t2ex* vdd p4.4-t2out p1.0-cs0-t2in p1.1-cs1-t2ex p1.2-cs2-pc1.1-rxd1-t2out* p1.3-cs3-txd1 p1.4-ss-t1out* wr-p3.6 vdd rd-p3.7 pwm4*-p5.4 pwm5*-p5.5 pwm6*-p5.6 pwm7*-p5.7 xtal1-p4.6 xtal2-p4.7 vss t1out-p4.0 pwm0-a8-p2.0 pwm1-a9-p2.1 pwm2-a10-p2.2 txd0*-pwm3-a11-p2.3 rxd0*-pwm4-a112-p2.4 p0.4-ad4 p0.5-ad5 p0.6-ad6 p0.7-ad7 p6.5-a5 p6.6-a6 p6.7-a7 pc1.2-t0ex-rxd1* t1ex-txd1* p4.3-tdi p4.2-td0 cm0-ale p4.1-tms p2.7-a15-pwm7-tck p2.6-a14-pwm6-t0ex p2.5-a13-pwm5-t1ex
VRS51L2070 ___________________ __________________ _______________ ______________ _______________ _______________ www.ramtron.com page 5 of 99 instruction set the following table describes the instruction set of the VRS51L2070. the instructions are binary code-compatible and perform the same functions as industry standard 8051s. t able 2: l egend for i nstruction s et t able symbol function a accumulator rn register r0-r7 direct internal register address @ri internal register pointed to by r0 or r1 (except movx) rel two's complement offset byte bit direct bit address #data 8-bit constant #data 16 16-bit constant addr 16 16-bit destination address addr 11 11-bit destination address t able 3: VRS51L2070 i nstruction s et mnemonic description size (bytes) instr. cycles hex code arithmetic instructions add a, rn add register to a 1 2 28h-2fh add a, direct add direct byte to a 2 3 25h add a, @ri add data memory to a 1 3 26h-27h add a, #data add immediate to a 2 2 24h addc a, rn add register to a with carry 1 2 38h-3fh addc a, direct add direct byte to a with carry 2 3 35h addc a, @ri add data memory to a with carry 1 3 36h-37h addc a, #data add immediate to a with carry 2 2 34h subb a, rn subtract register from a with borrow 1 2 98h-9fh subb a, direct subtract direct byte from a with borrow 2 3 95h subb a, @ri subtract data mem from a with borrow 1 3 96h-97h subb a, #data subtract immediate from a with borrow 2 2 94h inc a increment a 1 2 04h inc rn increment register 1 2 08h-0fh inc direct increment direct byte 2 3 05h inc @ri increment data memory 1 3 06h-07h dec a decrement a 1 2 14h dec rn decrement register 1 2 18h-1fh dec direct decrement direct byte 2 3 15h dec @ri decrement data memory 1 3 16h-17h inc dptr increment data pointer 1 2 a3h mul ab multiply a by b 1 2 a4h div ab divide a by b 1 2 84h da a decimal adjust a 1 4 d4h logical instructions anl a, rn and register to a 1 2 58h-5fh anl a, direct and direct byte to a 2 3 55h anl a, @ri and data memory to a 1 3 56h-57h anl a, #data and immediate to a 2 2 54h anl direct, a and a to direct byte 2 3 52h anl direct, #data and immediate data to direct byte 3 3 53h orl a, rn or register to a 1 2 48h-4fh orl a, direct or direct byte to a 2 3 45 orl a, @ri or data memory to a 1 3 46h-47h orl a, #data or immediate to a 2 2 44h orl direct, a or a to direct byte 2 3 42h orl direct, #data or immediate data to direct byte 3 3 43h xrl a, rn exclusive-or register to a 1 2 68h-6fh xrl a, direct exclusive-or direct byte to a 2 3 65h xrl a, @ri exclusive-or data memory to a 1 3 66h-67h xrl a, #data exclusive-or immediate to a 2 2 64h xrl direct, a exclusive-or a to direct byte 2 3 62h xrl direct, #data exclusive-or immediate to direct byte 3 3 63h clr a clear a 1 1 e4h cpl a compliment a 1 1 f4h swap a swap nibbles of a 1 1 c4h rl a rotate a left 1 1 23h rlc a rotate a left through carry 1 1 33h rr a rotate a right 1 1 03h rrc a rotate a right through carry 1 1 13h mnemonic description size (bytes) instr. cycles hex code boolean instruction clr c clear carry bit 1 1 c3h clr bit clear bit 2 4 c2h setb c set carry bit to 1 1 1 d3h setb bit set bit to 1 2 4 d2h cpl c complement carry bit 1 1 b3h cpl bit complement bit 2 4 b2h anl c,bit logical and between carry and bit 2 4 82h anl c,#bit logical and between carry and not bit 2 4 b0h orl c,bit logical orl between carry and bit 2 4 72h orl c,#bit logical orl between carry and not bit 2 4 a0h mov c,bit copy bit value into carry 2 4 a2h mov bit,c copy carry value into bit 2 3 92h data transfer instructions mov a, rn move register to a 1 2 e8h-efh mov a, direct move direct byte to a 2 3 e5h mov a, @ri move data memory to a 1 3 e6h-e7h mov a, #data move immediate to a 2 2 74h mov rn, a move a to register 1 1 f8h-ffh mov rn, direct move direct byte to register 2 3 a8h-afh mov rn, #data move immediate to register 2 2 78h-7fh mov direct, a move a to direct byte 2 3 f5h mov direct, rn move register to direct byte 2 3 88h-8fh mov direct, direct move direct byte to direct byte 3 3 85h mov direct, @ri move data memory to direct byte 2 3 86h-87h mov direct, #data move immediate to direct byte 3 3 75h mov @ri, a move a to data memory 1 2 f6h-f7h mov @ri, direct move direct byte to data memory 2 3 a6h-a7h mov @ri, #data move immediate to data memory 2 2 76h-77h mov dptr, #data move immediate to data pointer 3 3 90h movc a, @a+dptr move code byte relative dptr to a 1 3+1 93h movc a, @a+pc move code byte relative pc to a 1 3+1 83h movx a,{mpage, @ri} move external data (a8) to a 1 3* e2h-e3h movx a, @dptr move external data (a16) to a 1 2* e0h movx {mpage, @ri},a move a to external data (a8) 1 2* f2h-f3h movx @dptr, a move a to external data (a16) 1 1* f0h push direct push direct byte onto stack 2 3 c0h pop direct pop direct byte from stack 2 2 d0h xch a, rn exchange a and register 1 3 c8h-cfh xch a, direct exchange a and direct byte 2 4 c5h xch a, @ri exchange a and data memory 1 4 c6h-c7h xchd a, @ri exchange a and data memory nibble 1 4 d6h-d7h branching instructions acall addr 11 absolute call to subroutine 2 4+1 11h-f1h lcall addr 16 long call to subroutine 3 5+1 12h ret return from subroutine 1 3+1 22h reti return from interrupt 1 3+1 32h ajmp addr 11 absolute jump unconditional 2 2+1 01h-e1h ljmp addr 16 long jump unconditional 3 3+1 02h sjmp rel short jump (relative address) 2 3+1 80h jc rel jump on carry = 1 2 3+1 40h jnc rel jump on carry = 0 2 3+1 50h jb bit, rel jump on direct bit = 1 3 3 / 4 +1 20h jnb bit, rel jump on direct bit = 0 3 3 / 4 +1 30h jbc bit, rel jump on direct bit = 1 and clear 3 3 / 4 + 1 10h jmp @a+dptr jump indirect relative dptr 1 2+1 73h jz rel jump on accumulator = 0 2 3+1 60h jnz rel jump on accumulator 1= 0 2 3+1 70h cjne a , direct, rel compare a, direct jne relative 3 4 / 5 +1 b5h cjne a, #d, rel compare a, immediate jne relative 3 3 / 4 +1 b4h cjne rn, #d, rel compare reg, immediate jne relative 3 3 / 4 +1 b8h-bfh cjne @ri, #d, rel compare ind, immediate jne relative 3 4 / 5 + 1 b6h-b7h djnz rn, rel decrement register, jnz relative 2 3 / 4 +1 d8h-dfh djnz direct, rel decrement direct byte, jnz relative 3 3 / 4 +1 d5 miscellaneous instruction nop no operation 1 1 00h nop if pcon.4 is 0 (reset value): nop 1 1 a5h mov @ramptr,a if msb (@ramptr) == 0 accumulator value is written in sfr{1,@ramptr[6:0]} 2 3 a5h mov a,@ramptr if msb (@ramptr) == 1 sfr{1,@ramptr[6:0]} is written in accumulator 3 4 a5h rn: any of the register r0 to r7 @ri: indirect addressing using register r0 or r1 #data: immediate data provided with instruction #data16: immediate data included with instruction bit: address at the bit level rel: relative address to program counter from +127 to ?128 addr11: 11-bit address range addr16: 16-bit address range #d: immediate data supplied with instruction
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 6 of 99 special function registers (sfr) addresses 80h to ffh of the sfr address space can be acce ssed in direct addressing mo de only. the following table lists the VRS51L2070 special function registers. due to t he VRS51L2070?s high level of integration, the sfrs have been mapped into two pages. the following tables summarize the sfr assignment. comp lete functional description s of each register will be provided throughout the datasheet. 1.1 sfr map page 0 t able 4: s pecial f unction r egisters (sfr) p age 0 sfr register sfr adrs bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 reset value p0 80h - - - - - - - - 1111 1111b sp 81h - - - - - - - - 0000 0111b dpl0 82h - - - - - - - - 0000 0000b dph0 83h - - - - - - - - 0000 0000b dpl1 84h 0000 0000b dph1 85h 0000 0000b dps 86h dpsel 0000 0000b pcon 87h oscstop intmoden devcfgen sfrindadr gf1 gf0 pdown idle 0110 0000b inten1 88h t1ien u1ien u0ien pchgien0 t0ien spirxovien spitxeien - 0000 0000b t0t1cfg 89h - t1gate t0gate t1clksrc t1outen t1mode8 t0outen t0mode8 0000 0000b tl0 8ah 0000 0000b th0 8bh 0000 0000b tl1 8ch 0000 0000b th1 8dh 0000 0000b tl2 8eh 0000 0000b th2 8fh 0000 0000b p1 90h - - - - - - - - 1111 1111b wdtcfg 91h wdtperiod3 wdtperiod2 wdtperiod1 wdtperiod0 wtimerf astimer wdtf wdtreset 0000 0000b rcap0l 92h 0000 0000b rcap0h 93h 0000 0000b rcap1l 94h 0000 0000b rcap1h 95h 0000 0000b rcap2l 96h 0000 0000b rcap2h 97h 0000 0000b p5 98h 1111 1111b t0t1clkcfg 99h t1clkcfg3 t1clkcfg2 t1clkcfg1 t1clkcfg0 t0clkcfg3 t0clkcfg2 t0clkcfg1 t0clkcfg0 0000 0000b t0con 9ah t0ovf t0exf t0downen t0togout t0exten tr0 t0counten t0rlcap 0000 0000b t1con 9bh t1ovf t1exf t1downen t1togout t1exten tr1 t1counten t1rlcap 0000 0000b t2con 9ch t2ovf t2exf t2downen t2togout t2exten tr2 t2counten t2rlcap 0000 0000b t2clkcfg 9dh - - t2clksrc t2outen t2clkcfg3 t2clkcfg2 t2clkcfg1 t2clkcfg0 0000 0000b pwc0cfg 9eh pwc0if pwc0rst pwc0end pwc0start pwc0endsrc1 pwc0endsrc0 pwc0stsrc1 pwc0stsrc0 0000 0000b pwc1cfg 9fh pwc1if pwc1rst pwc1end pwc1start pwc1endsrc1 pwc1endsrc0 pwc1stsrc1 pwc1stsrc0 0000 0000b p2 a0h - - - - - - - - 1111 1111b uart0int a1h colen rxoven rxavailen txemptyen colenf rxovf rxavenf txemptyf 0000 0001b uart0cfg a2h bradj3 bradj2 bradj1 bradj0 brclksrc b9rxtx b9en stop2en 1110 0000b uart0buf a3h 0000 0000b uart0brl a4h 0000 0000b uart0brh a5h 0000 0000b uart0ext a6h u0timerf u0timeren u0rxstate multiproc j1708pri3 j1708pri2 j1708pri1 j1708pri0 0010 0000b reserved a7h
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 7 of 99 inten2 a8h pchgien1 auwdtien pwmt47ien pwmt03ien pwcien i2cuartci i2cien t2ien 0000 0000b pwmcfg a9h - pwmwait pwmclrall pwmlsbmsb pwmmidend pwmch2 pwmch1 pwmch0 0000 0000b pwmen aah pwm7en pwm6en pwm5en pwm4en pwm3en pwm2en pwm1en pwm0en 0000 0000b pwmldpol abh pwm7ldpol pwm6ldpol pwm5ldpol pwm4ldpol pwm3ldpol pwm2ldpol pwm1ldpol pwm0ldpol 0000 0000b pwmdata ach 0000 0000b pwmtmren adh pwm7tmren pwm6tmren pwm5tmren pwm4tmren pwm3tmren pwm2tmren pwm1tmren pwm0tmren 0000 0000b pwmtmrf aeh pwm7tmrf pwm6tmrf pwm5tmrf pwm4tmrf pwm3tmrf pwm2tmrf pwm1tmrf pwm0tmrf 0000 0000b pwmclkcfg afh u4pwmclk3 u4pwmclk2 u4pwmclk1 u4pwmclk0 l4pwmclk3 l4pwmdclk2 l4pwmclk1 l4pwmclk0 0000 0000b p3 b0h - - - - - - - - 1111 1011b uart1int b1h colen rxoven rxavailen txemptyen colenf rxovf rxavenf txemptyf 0000 0001b uart1cfg b2h bradj3 bradj2 bradj1 bradj0 brclksrc b9rxtx b9en stop2en 1110 0000b uart1buf b3h 0000 0000b uart1brl b4h 0000 0000b uart1brh b5h 0000 0000b uart1ext b6h u1timerf u1timeren u1rxstate multiproc j1708pri3 j1708pri2 j1708pri1 j1708pri0 0010 0000b not used b7h ipinflag1 b8h p37if p36if p35if p34if p31if p30if int1if int0if 0000 0000b portchg b9h pmonflag1 pchgmsk1 pchgsel1 pchgsel0 pmonflag0 pchgmsk0 pchgsel1 pchgsel0 0000 0000b p4 c0h 1111 1111b spictrl c1h spiclk2 spiclk1 spiclk0 spics1 spics0 spiclkph spiclkpol spimaster 0000 0001b spiconfig c2h spimancs spiunderc fsoncs3 spiloadcs3 spislow spirxoven spirxaven spitxeen 0000 0000b spisize c3h 0000 0111b spirxtx0 c4h 0000 0000b spirxtx1 c5h 0000 0000b spirxtx2 c6h 0000 0000b spirxtx3 c7h 0000 0000b p6 c8h 1111 1111b spistatus c9h spireverse - spiunderf sspinval spinocs spirxovf spirxavf spitxempf 0011 1001b psw d0h cy ac f0 rs1 rs0 ov - p 0000 0000b i2cconfig d1h mastrarb i2crxoven i2crxaven i2ctxeen i2cmastart i2cscllow i2crxstop i2cmode 0000 0100b i2ctiming d2h 0000 1100b i2cidcfg d3h i2cid6 i2cid5 i2cid4 i2cid3 i2cid2 i2cid1 i2cid0 i2cadvcfg 0000 0000b i2cstatus d4h i2cerror i2cnoack i2csdasync i2cackph i2cidlef i2crxovf i2crxavf i2ctxempf 0010 1001b i2crxtx d5h 0000 0000b ipininv1 d6h p37iinv p36iinv p35iinv p34iinv p33iinv p32iinv p31iinv p30iinv 0000 0000b ipininv2 d7h p07iinv p06iinv p05iinv p04iinv p03iinv p02iinv p01iinv p00iinv 0000 0000b ipinflag2 d8h p07if p06if p05if p04if p03if p02if p01if p00if 0000 0000b xmemctrl d9h extbuscfg extbuscs - - strech3 strech2 strech1 strech0 0000 0000b reserved dah - - - - - - - - 0000 0000b reserved dbh - - - - - - - - 0000 0000b reserved dch - - - - - - - - 0000 0000b reserved ddh - - - - - - - - 0000 0000b reserved deh - - - - - - - - 0000 0000b reserved dfh - - - - - - - - 0000 0000b acc e0h - - - - - - - - 0000 0000b deviomap e1h reserved pwmaltmap i2caltmap u1altmap u0altmap t2altmap t1altmap t0altmap 0000 0000b intpri1 e2h t1p37pri u1p36pri u0p35pri pc0p34pri t0p31pri srp30pri stp33pri int0p32pri 0000 0000b intpri2 e3h pc1p00pri aup06pri pthp05pri ptlp04pri pwcp23pri i10p02pri i2cp01pri t2p00pri 0000 0000b intsrc1 e4h intsrc1.7 intsrc1.6 intsrc1.5 intsrc1.4 intsrc1.3 intsrc1.2 intsrc1.1 intsrc1.0 0000 0000b intsrc2 e5h intsrc2.7 intsrc2.6 intsrc2.5 intsrc2.4 intsrc2.3 intsrc2.2 intsrc2.1 intsrc2.0 0000 0000b intpinsens1 e6h p37isens p36isens p35isens p34isens p33isens p32isens p31isens p30isens 0000 0000b
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 8 of 99 intpinsens2 e7h p07isens p06isens p05isens p04isens p03isens p02isens p01isens p00isens 0000 0000b geninten e8h - - - - - - geninten 0000 0000b fpiconfig e9h fpilock1 fpilock0 fpiidle fpirdy 0 fpi8bit fpitask1 fpitask0 0000 0100b fpiaddrl eah 0000 0000b fpiaddrh ebh 0000 0000b fpidatal ech 0000 0000b fpidatah edh 0000 0000b fpiclkspd eeh fpiclkspd3 fpiclkspd2 fpiclkspd1 fpiclkspd0 0000 0000b reserved efh - - - - - - - - 0000 0000b b f0h 0000 0000b mpage f1h 0000 0000b devclkcfg1 f2h softreset oscselect clkdiven fullspdint clkdiv3 clkdiv2 clkdiv1 clkdiv0 0011 0000b devclkcgf2 f3h cyoscen intoscen - - cyrange1 cyrange0 0 systemrdy 0100 1001b periphen1 f4h spicsen spien i2cen u1en u0en t2en t1en t0en 0000 0000b periphen2 f5h pwc1en pwc0en auen xram2code ioporten wdten pwmsfren fpien 0000 1000b devmemcfg f6h extbusen - - - - - - sfrpage 0000 0000b portinen f7h reserved (0) p6inputen p5inputen p4inputen p3inputen p2inputen p1inputen p0inputen 0111 1111b userflags f8h 0000 0000b p0pincfg f9h p07in1out0 p06in1out0 p05in1out0 p04in1out0 p03in1out0 p02in1out0 p01in1out0 p00in1out0 1111 1111b p1pincfg fah p17in1out0 p16in1out0 p15in1out0 p14in1out0 p13in1out0 p12in1out0 p11in1out0 p10in1out0 1111 1111b p2pincfg fbh p27in1out0 p26in1out0 p25in1out0 p24in1out0 p23in1out0 p22in1out0 p21in1out0 p20in1out0 1111 1111b p3pincfg fch p37in1out0 p36in1out0 p35in1out0 p34in1out0 p33in1out0 p32in1out0 p31in1out0 p30in1out0 1111 1111b p4pincfg fdh p47in1out0 p46in1out0 p45in1out0 p44in1out0 p43in1out0 p42in1out0 p41in1out0 p40in1out0 1111 1111b p5pincfg feh p57in1out0 p56in1out0 p55in1out0 p54in1out0 p53in1out0 p52in1out0 p51in1out0 p50in1out0 1111 1111b p6pincfg ffh p67in1out0 p66in1out0 p65in1out0 p64in1out0 p63in1out0 p62in1out0 p61in1out0 p60in1out0 1111 1111b
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 9 of 99 1.2 sfr map page 1 t able 5: s pecial f unction r egisters (sfr) p age 1 sfr register sfr adrs bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 reset value p0 80h - - - - - - - - 1111 1111b sp 81h - - - - - - - - 0000 0111b dpl0 82h - - - - - - - - 0000 0000b dph0 83h - - - - - - - - 0000 0000b dpl1 84h 0000 0000b dph1 85h 0000 0000b dps 86h dpsel 0000 0000b pcon 87h oscstop intmoden devcfgen sfrindadr gf1 gf0 pdown idle 0110 0000b inten1 88h t1ien u1ien u0ien pchgien0 t0ien spirxovien spitxeien - 0000 0000b t0t1cfg 89h - t1gate t0gate t1clksrc t1outen t1mode8 t0outen t0mode8 0000 0000b tl0 8ah 0000 0000b th0 8bh 0000 0000b tl1 8ch 0000 0000b th1 8dh 0000 0000b tl2 8eh 0000 0000b th2 8fh 0000 0000b p1 90h - - - - - - - - 1111 1111b wdtcfg 91h wdtperiod3 wdtperiod2 wdtperiod1 wdtperiod0 wtimerf astimer wdtf wdtreset 0000 0000b rcap0l 92h 0000 0000b rcap0h 93h 0000 0000b rcap1l 94h 0000 0000b rcap1h 95h 0000 0000b rcap2l 96h 0000 0000b rcap2h 97h 0000 0000b p5 98h 1111 1111b t0t1clkcfg 99h t1clkcfg3 t1clkcfg2 t1clkcfg1 t1clkcfg0 t0clkcfg3 t0clkcfg2 t0clkcfg1 t0clkcfg0 0000 0000b t0con 9ah t0ovf t0exf t0downen t0togout t0exten tr0 t0counten t0rlcap 0000 0000b t1con 9bh t1ovf t1exf t1downen t1togout t1exten tr1 t1counten t1rlcap 0000 0000b t2con 9ch t2ovf t2exf t2downen t2togout t2exten tr2 t2counten t2rlcap 0000 0000b t2clkcfg 9dh - - t2clksrc t2outen t2clkcfg3 t2clkcfg2 t2clkcfg1 t2clkcfg0 0000 0000b reserved 9eh - - - - - - - - 0000 0000b reserved 9fh - - - - - - - - 0000 0000b p2 a0h - - - - - - - - 1111 1111b reserved a1h - - - - - - - - 0000 0000b aua0 a2h* 0010 0000b aua1 a3h* 0010 0000b auc0 a4h* 0010 0000b auc1 a5h* 0010 0000b auc2 a6h* 0010 0000b auc3 a7h* 0010 0000b inten2 a8h pchgien1 auwdtien pwmt47ien pwmt03ien pwcien i2cuartci i2cien t2ien 0000 0000b p3 b0h - - - - - - - - 1111 1011b aub0div b1h* 0010 0000b aub0 b2h* 0010 0000b aub1 b3h* 0010 0000b aures0 b4h* 0010 0000b aures1 b5h* 0010 0000b
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 10 of 99 aures2 b6h* 0010 0000b aures3 b7h* 0010 0000b ipinflag1 b8h p37if p36if p35if p34if p31if p30if int1if int0if 0000 0000b portchg b9h pmonflag1 pchgmsk1 pchgsel1 pchgsel0 pmonflag0 pchgmsk0 pchgsel1 pchgsel0 0000 0000b reserved bah - - - - - - - - 0001 0000b reserved bbh - - - - - - - - 0000 0000b reserved bch - - - - - - - - 0000 0000b reserved bdh - - - - - - - - 0000 0000b reserved beh - - - - - - - - reserved bfh - - - - - - - - p4 c0h 1111 1111b aushiftcfg c1h* shiftmode arithshift shift5 shift4 shift3 shift2 shift1 shift0 0010 0000b auconfig1 c2h* capprev capmode ovcapen readcap addsrc1 addsrc0 mulcmd1 mulcmd0 0000 0000b auconfig2 c3h* auregclr2 auregclr1 auregclr0 auinten - divoutrg auov16 auov32 0000 0000b auprev0 c4h* 0000 0000b auprev1 c5h* 0000 0000b auprev2 c6h* 0000 0000b auprev3 c7h* 0000 0000b p6 c8h 0000 0000b reserved c9h - - - - - - - - 0000 0000b reserved cah - - - - - - - - 0000 0001b reserved cbh - - - - - - - - 0000 0000b reserved cch - - - - - - - - 0000 0000b reserved cdh - - - - - - - - 0000 0000b reserved ceh - - - - - - - - 0000 0000b reserved cfh - - - - - - - - psw d0h cy ac f0 rs1 rs0 ov - p 0000 0000b reserved d1h - - - - - - - - reserved d2h - - - - - - - - reserved d3h - - - - - - - - reserved d4h - - - - - - - - reserved d5h - - - - - - - - intpininv1 d6h p37iinv p36iinv p35iinv p34iinv p33iinv p32iinv p31iinv p30iinv 0000 0000b intpininv2 d7h p07iinv p06iinv p05iinv p04iinv p03iinv p02iinv p01iinv p00iinv 0000 0000b ipinflag2 d8h p07if p06if p05if p04if p03if p02if p01if p00if 0000 0000b xmemctrl d9h extbuscfg extbuscs - - strech3 strech2 strech1 strech0 0000 0000b reserved dah - - - - - - - - 0000 0000b reserved dbh - - - - - - - - 0000 0000b reserved dch - - - - - - - - 0000 0000b reserved ddh - - - - - - - - 0000 0000b reserved deh - - - - - - - - 0000 0000b reserved dfh - - - - - - - - 0000 0000b acc e0h - - - - - - - - 0000 0000b deviomap e1h reserved pwmaltmap i2caltmap u1altmap u0altmap t2altmap t1altmap t0altmap 0000 0000b intpri1 e2h t1p37pri u1p36pri u0p35pri pc0p34pri t0p31pri srp30pri stp33pri int0p32pri 0000 0000b intpri2 e3h pc1p00pri aup06pri pthp05pri ptlp04pri pwcp23pri i10p02pri i2cp01pri t2p00pri 0000 0000b intsrc1 e4h intsrc1.7 intsrc1.6 intsrc1.5 intsrc1.4 intsrc1.3 intsrc1.2 intsrc1.1 intsrc1.0 0000 0000b intsrc2 e5h intsrc2.7 intsrc2.6 intsrc2.5 intsrc2.4 intsrc2.3 intsrc2.2 intsrc2.1 intsrc2.0 0000 0000b intpinsens1 e6h p37isens p36isens p35isens p34isens p33isens p32isens p31isens p30isens 0000 0000b intpinsens2 e7h p07isens p06isens p05isens p04isens p03isens p02isens p01isens p00isens 0000 0000b geninten e8h - - - - - - geninten 0000 0000b
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 11 of 99 fpiconfig e9h fpilock1 fpilock0 fpiidle fpirdy 0 fpi8bit fpitask1 fpitask0 0000 0100b fpiaddrl eah 0000 0000b fpiaddrh ebh 0000 0000b fpidatal ech 0000 0000b fpidatah edh 0000 0000b fpiclkspd eeh fpiclkspd3 fpiclkspd2 fpiclkspd1 fpiclkspd0 0000 0000b reserved efh - - - - - - - - 0000 0000b b f0h 0000 0000b mpage f1h 0000 0000b devclkcfg1 f2h softreset oscselect clkdiven fullspdint clkdiv3 clkdiv2 clkdiv1 clkdiv0 0011 0000b devclkcgf2 f3h cyoscen intoscen - - cyrange1 cyrange0 0 systemrdy 0100 1001b periphen1 f4h spicsen spien i2cen u1en u0en t2en t1en t0en 0000 0000b periphen2 f5h pwc1en pwc0en auen xram2code ioporten wdten pwmsfren fpien 0000 1000b devmemcfg f6h extbusen - - - - - - sfrpage 0000 0000b portinen f7h reserved (0) p6inputen p5inputen p4inputen p3inputen p2inputen p1inputen p0inputen 0111 1111b userflags f8h 0000 0000b p0pincfg f9h p07in1out0 p06in1out0 p05in1out0 p04in1out0 p03in1out0 p02in1out0 p01in1out0 p00in1out0 1111 1111b p1pincfg fah p17in1out0 p16in1out0 p15in1out0 p14in1out0 p13in1out0 p12in1out0 p11in1out0 p10in1out0 1111 1111b p2pincfg fbh p27in1out0 p26in1out0 p25in1out0 p24in1out0 p23in1out0 p22in1out0 p21in1out0 p20in1out0 1111 1111b p3pincfg fch p37in1out0 p36in1out0 p35in1out0 p34in1out0 p33in1out0 p32in1out0 p31in1out0 p30in1out0 1111 1111b p4pincfg fdh p47in1out0 p46in1out0 p45in1out0 p44in1out0 p43in1out0 p42in1out0 p41in1out0 p40in1out0 1111 1111b p5pincfg feh p57in1out0 p56in1out0 p55in1out0 p54in1out0 p53in1out0 p52in1out0 p51in1out0 p50in1out0 1111 1111b p6pincfg ffh p67in1out0 p66in1out0 p65in1out0 p64in1out0 p63in1out0 p62in1out0 p61in1out0 p60in1out0 1111 1111b 1.3 bit accessible registers as is the case in the standard 8051, all sfr registers in wh ich the lower nibble of the address is x0 or x8 are bit- addressable. the bit-addressable register s allow bit-oriented instructions to alter individual register bit values. t able 6:b it addressable sfr r egisters sfr register sfr adrs bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 reset value p0 80h - - - - - - - - 1111 1111b inten1 88h t1ien u1ien u0ien pchgien0 t0ien spirxovien spitxeien - 0000 0000b p1 90h - - - - - - - - 1111 1111b p5 98h 1111 1111b p2 a0h - - - - - - - - 1111 1111b inten2 a8h pchgien1 auwdtien pwmt47ien pwmt03ien pwcien i2cuartci i2cien t2ien 0000 0000b p3 b0h - - - - - - - - 1111 1011b ipinflag1 b8h p37if p36if p35if p34if p31if p30if int1if int0if 0000 0000b p6 c8h 1111 1111b psw d0h cy ac f0 rs1 rs0 ov - p 0000 0000b ipinflag2 d8h p07if p06if p05if p04if p03if p02if p01if p00if 0000 0000b acc e0h - - - - - - - - 0000 0000b geninten e8h - - - - - - geninten 0000 0000b b f0h 0000 0000b userflags f8h 0000 0000b
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 12 of 99 1 VRS51L2070 architecture 1.1 data pointers the VRS51L2070 includes two 16-bit data pointers which are described in the following tables. the active data pointer is controlled via dps register is located at sfr address 86h (see below). t able 7: d ata p ointer 0 h igh - dph0 sfr 83 h 7 6 5 4 3 2 1 0 r/w, reset = 0x00 dptr0[15:8] t able 8: d ata p ointer 0 low - dpl0 sfr 82 h 7 6 5 4 3 2 1 0 r/w, reset = 0x00 dptr0[7:0] t able 9: d ata p ointer 1 h igh - dph1 sfr 85 h 7 6 5 4 3 2 1 0 r/w, reset = 0x00 dptr1[15:8] t able 10: d ata p ointer 1 low - dpl1 sfr 84 h 7 6 5 4 3 2 1 0 r/w, reset = 0x00 dptr1[7:0] t able 11: d ata p ointer s elect r egister - dps sfr 86 h 7 6 5 4 3 2 1 0 r r r r r r r r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:1 unused 0 dpsel dps value 0 : selects dptr 0 1 : selects dptr 1 1.2 psw register the psw register is a bit addressable register that contains the status flags (cy, ac, ov, p), user flag (f0) and register bank select bits (rs1, rs0) of the 8051 processor t able 12:t he psw sfr register - psw sfr d0 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 cy carry bit flag. indicates that the last addition/subtraction resulted in a carry or borrow. the cy bit is cleared by other arithmetic instructions, the jbc and clr c instructions. 6 ac auxiliary carry bit flag. indicates that the last addition/subtraction resulted in a carry or borrow from the higher nibble. the ac bit is cleared by other arithmetic instructions and by the jbc instruction. 5 f0 user general purpose flag 4:3 rs1:rs0 register select address for r0 ? r7 00 r0 to r7 from 00h to 07h 01 r0 to r7 from 08h to 0fh 10 r0 to r7 from 10h to 17h 11 r0 to r7 from 17h to 1fh 2 ov overflow flag indicates that the last addition/subtraction resulted in a carry/borrow/overflow. the ov bit is cleared by other arithmetic instructions and the jbc instruction. 1 f1 user general purpose flag 0 p parity flag 1.3 accumulator, b and user flags register the VRS51L2070 accumulator is located at address e0h on sfr pages 0 and 1. the accumulator is the source and destination for many 8051 instructions. t able 13: t he a ccumulator - acc or a sfr e0 h 7 6 5 4 3 2 1 0 r/w, reset = 0x00 acc[7:0] the b register is mainly used for mul and div instructions, holding the msb of the mul instruction and the remainder of the div instruction. it can also be used as a general purpose register that is bit- addressable. it is accessible via both sfr pages 0 and 1 at address f0h. t able 14: b r egister - sfr f0 h 7 6 5 4 3 2 1 0 r/w, reset = 0x00 b[7:0] 1.4 user flag register the user flag register is a bit-addressable register used for condition testing or as a general purpose storage register. t able 15: userflags r egister - userflags sfr f8 h 7 6 5 4 3 2 1 0 userflags, reset = 0x00 userflags[7:0]
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 13 of 99 2 VRS51L2070 program memory the VRS51L2070 includes 64kb of on-chip flash memory that can be used as program memory or as nonvolatile data storage. 2.1 programming the VRS51L2070 the VRS51L2070 on-board flash memory is programmed through its jtag interface or via the fpi interface. the VRS51L2070 cannot be programmed in parallel mode (section 21 of this datasheet explains the fpi interface operation). 3 data memory the VRS51L2070 has a total of 4352 bytes of on-chip sram memory: 256 bytes are configured as the standard internal memory structure of an 8051, while the remaining 4096 bytes can be accessed using external memory addressing (movx instructions). f igure 4: VRS51L2070 d ata and p rogram m emory s tructure upper 128 bytes sram (indirect addressing only) lower 128 bytes sram program memory 64kb flash (no external program memory access) 0fffh 0000h 8000h ffffh ffh 80h 7fh 00h 4096 bytes of sram (accessible using movx instruction) 0fffh 0000h sfr page 1 (devmemcfg.0=1) sfr page 0 (devmemcfg.0=0) 80h ffh 80h ffh external data bus access (upper 32kb) (devmemcfg.7 = 1) 8000h ffffh the VRS51L2070 also provides external data bus memory access, enabling direct interfacing of the VRS51L2070 to external devices such as sram, data converters, etc. bit 7 of the devmemcfg register, when set, will activate external data bus access. 3.1 internal scratch pad sram (256 bytes) as is the case with standard 8051s, the VRS51L2070 includes 256 bytes of internal scratch pad sram: the lower 128 bytes are accessible by using either direct or indirect addressing; the upper 128 bytes are accessible by using indirect addressing only. using direct addressing for the upper 128 bytes of scratch pad sram will access the sfr register area. 3.2 sfr register structure the VRS51L2070 peripheral registers are accessible through two sfr register pages mapped into address range 80h to ffh in the 256 bytes of memory, which can be addressed directly or indirectly. most peripherals are accessible via both sfr pages. the following peripherals are only accessible via sfr page 0: o i2c interface o spi interface o pwc interface the enhanced arithmetic unit is only mapped into sfr page 1. the active sfr page is selected by using the device memory configuration register. t able 16:d evice memory c onfiguration r egister - devmemcfg sfr f6 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 extbusen when set this bit activates the external data bus access through port 0, port 2, p3.6 and p3.7 6:2 not used 0 sfrpage when set, sfr page 1 is selected. 3.3 accessing sfr page 1 accessing registers located on sfr page 1 requires writing a 01h to the devmemcfg register, as shown below: mov devmemcfg,#01h ;select sfr page 1 writing 00h into the devmemcfg register enables access to sfr page 0. mov devmemcfg,#00h ;select sfr page 0 3.4 indirect addressing of the sfr it is possible to access the sfr register in indirect addressing mode. unique to the VRS51L2070, this feature enables efficient sf r content data transfers. when the sfrindadr bit 4 of the pcon register is set to 1, the a5h (nop) instruction functions as an indirect sfr access. indirect sfr addressing uses the accumulator as well as the four bank rn registers of sram memory area 00h to 1fh to indirectly transfer the data to and from the sfr memory space. 3.4.1 indirect sfr register write for an indirect sfr write operation, perform the following steps after the sfrindadr bit of the pcon register is set to 1: o write the data value into the accumulator. o hold the sfr address where the write operation is performed in the internal sram memory from address 00h to 1fh. the same sram memory area [00f to 1fh] holds four sets of 8x rn registers that are used for indirect
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 14 of 99 addressing. only one set of rn registers is active at any given time and is defined by the value of the bits rs1 and rs0 of the psw register. for an indirect sfr write operation, bit 7 of the sfr address written into rn must be cleared. for example, to write to the spitx0 register located at address c4h, 44h should be written into the rn register. example using the bank 1, r0 register: mov r0,#44 ;target is sfr c4h (with bit 7 stripped) example using the bank 1, r3 register: mov r3,#44 ;target is sfr c4h (with bit 7 stripped) the next step involves calling the sfr indirect addressing function. this is a two-step process composed of the a5h instruct ion itself followed by the physical address of the rn register, where the sfr address is stored. if the r0 register of bank 1 has been used, the next instructions should be: db. 0xa5 db. 0x00 if the r3 register of bank 0 has been used, the next instructions should be: db. 0xa5 db. 0x03 this would also work for the rn registers located in bank 4. for example, if t he r0 register of bank 4 contains the target sfr address, the instruction should be: db. 0xa5 db. 0x18 once the a5h instruction is executed, the processor will take the value stored in the accumulator and put it into the sfr address identified by the rn register address. ;// perform indirect write of value 0xaa ;// into userflags sfr address (0xf8) using indirect sfr write orl 0x87, #0x10; ;set a5 for indirect sfr addressing mov 0xf8,#00 ;clear userflags mov a, #0xaa ;acc = aah mov r0, #0x78 ;r0 (bank1) = address userflags (f8h) ;with bit 7 cleared .db 0xa5 ;perform the indirect sfr write .db 0x00 ;after the second .db instruction, ;p2 contain the value 0xaa anl 0x87, #0xef; ;set a5 for nop operation 3.4.2 indirect sfr read the indirect sfr address read functions similarly to the indirect sfr write, with the main differences being that the sfr target address st ored in the rn register is the actual sfr address (bit 7 = 1) with the accumulator containing the current sfr data. ;// perform indirect read of value in userflags sfr address (0xf8) ;// into acc using indirect sfr read function orl 0x87, #0x10; ;set a5 for indirect sfr addressing mov a,#0x00 ;acc = 00h mov r0, #0xf8 ;r0 (bank1) = address p2 with bit 7 cleared .db 0xa5 ;perform the indirect sfr write .db 0x00 ;after the second .db instruction, ;acc contain the value 0xaa anl 0x87, #0xef; ;set a5 for nop operation 3.5 stack pointer the stack pointer is a register located at address 81h of the sfr register area whose value corresponds to the address of the last it em that was put on the processor stack. each time new data is put on the processor stack, the value of the stack pointer is incremented. t able 17: s tack p ointer - sp sfr 81 h 7 6 5 4 3 2 1 0 r/w, reset = 0x07 sp[7:0] by default, the stack pointer value is 07h. the stack can be set anywhere in the internal sram from address 00h to ffh. each time a function call is performed or an interrupt is serviced, the 16-bit return address (2 bytes) is stored on the stack. data can be manually placed on the stack by using the push and pop functions. 3.6 external data memory access the VRS51L2070 provides external memory bus access on the upper 32kb block of the 64kb external memory [8000h to ffffh]. external memory bus access requires that the extbusen bit of the devmemcfg register be set to 1. the external memory address range 0000h to 3fffh provides access to a block of 4kb of sram memory on the device.
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 15 of 99 t able 18: xmem c ontrol r egister - xmemctrl sfr d9 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 extbuscfg external memory bus configuration 0 = lsb of address/data are multiplexed 1 = lsb of address/data are not multiplexed 6 extbuscs ext memory cs function 0 = full address bit dedicated to addressing 1 = a12: a15 becomes cs lines 5 - not used 4 - not used 3:0 stretch[3:0] number of st retch cycles from 0 to 15 from a device connected to the VRS51L2070?s external memory bus, the address range is seen as 0000 to 7fffh, as p2.7/a15 is driven low. 3.7 integrated 4kb sram block the VRS51L2070 includes a 4kb block of sram that is mapped from address 0000h to 0fffh on the external memory bus. this sram can be used for general purpose data memory or program memory. 3.7.1 accessing the 4kb sram block access to the block of 4kb sram requires the use of movx instructions. 3.7.2 running programs from the external 4kb sram block here, the VRS51L2070 processor can execute code directly from the external 4kb of sram. running the program from the sram memory can significantly save power, especially at lower operating frequencies. this is because sram power consumption is directly proportional to the access frequency, while power consumption of the flash memory is less dependant of the VRS51L2070 operating frequency to execute code from the 4kb sram block: 1. copy the code from the flash to the sram and apply the appropriate address shifting, if required 2. before switching to an xram operation, the program must execute from a flash address higher than 0fffh 3. set the xram2code bit (bit 4) of the periphen2 register 4. jump to the code copied into xram the following program example copies code from the flash memory to the xram memory and switches the program execution to the xram ;--------VRS51L2070 - running program into xram --------------- ;- description: this program gives an examples on how ;- to switch code execution from flash to xram ;--------------------------------------------------------------- include VRS51L2070_ride.inc ;---------- variable definition -------------- cptr equ 030h org 00000h ljmp init ;------------------------------------------------------------------------ ;---------------------- main program begins ----------------------------- ;------------------------------------------------------------------------ init: mov periphen2,#08h ;enable io mov p1pincfg,#00h ;configure p1 as output mov periphen1,#00000000b; mov periphen2,#00001000b ;bit4 - xram2code = 0 ;--copy code from flash into xram memory clr dps mov dptr,#01000h ;set dptr0 (point to code) mov dps,#01h ;switch to dptr1 mov dptr,#0000h ;set dptr1 (point to xram) copyloop: mov dps,#00 ;point to dptr0 (flash) clr a movc a,@a+dptr ; inc dptr ;inc dptr0 (flash) mov dps,#01h ;switch to dptr1 (xram) movx @dptr,a ;write value into xram inc dptr ;inc dptr1 (xram) mov a,dph1 ;check if dptr1 (xram) reach address 0300h cjne a,#03,copyloop ljmp outsidexram ;jump to flash location outside xram area ;------------------------------------------ ;- section of code outside the xram ;------------------------------------------ org 2000h outsidexram: mov periphen2,#18h ;activate xram2code bit and ioports ;any jump to the 0000h - 0fffh area should execute from xram ljmp 0100h ;jump to the p1 toggle loop copied into xram mov p1,#00 ;force p1 = 0x00h if stuck into the flash loop: ljmp loop ;infinite loop ;----------------------------------------------------------------------------------- ;- code to be moved into xram from address 0000h to 02ffh ; assumed code contained from 1000h to 12ffh... ; will be copied from 0000h to 02ffh into xram ;------------------------------------------------------------------------------------ ;-------------------------------------- ;- xram_port_toggle: ;-------------------------------------- org 1100h toggle: mov p1,#00h ;set port 1 = 00h lcall 0200h ;call delay function mov p1,#0ffh ;set port 1 = ffh lcall 0200h ;call delay function ljmp 0100h org 1200h ;---------------------------------------------------------------- ;- delay1msto : 1ms delay using timer0 ;--------------------------------------------------------------- delay1ms: mov cptr,#1 mov a,periphen1 ;load periphen1 reg orl a,#00000001b ;enable timer 0 mov periphen1,a
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 16 of 99 delay1mslp: mov th0,#063h ; 6timer0 reload value for 1ms at 40mhz mov tl0,#0c0h mov t0t1clkcfg,#00h ;no prescaler for timer 0 clock mov t0con,#00000100b ;start timer 0, count up dwaitovt0: mov a,t0con ;read timer 0 control, wait for overflow anl a,#080h ;isolate timer overflow flag jz dwaitovt0 ;loop as long as timer 0 dont overflow mov t0con,#00h ;stop timer 0 djnz cptr,delay1mslp ; mov a,periphen1 ;load periphen1 reg anl a,#11111110b ;disable timer 0 mov periphen1,a ret 3.8 external data bus access the VRS51L2070 provides 32kb of data memory access, which is mapped from address 8000h to ffffh. bit 7 of the devmemcfg register, when set, activates the external data me mory bus access. in this mode, port 0 and port 2 are dedicated to external device addressing. 3.8.1 multiplexed external data memory access multiplexed external data memory access mode on the VRS51L2070 is similar to that on standard 8051s: address bits a0 to a7 and data bits d0 to d7 are time- multiplexed on port 0, while port 2 controls address bits a8 to a15. in multiplexed addressing mode, external glue logic is required to multiplex lower addresses and data. typically, a 74x373 or 74x573 can be used for this purpose. the ale-cm0 pin serves to latch the address. f igure 5: m ultiplexed e xternal data memory access p2 a[14:8] p0 a[7:0]/d[7:0] clk p2 a[14:8] p0 a[7:0]/d[7:0] ale wr clk a[7:0] d[7:0] multiplexed write ale rd a[7:0] multiplexed read data the multiplexed addressing mode is the default configuration when external memory access is performed. 3.8.2 non-multiplexed external data memory access the VRS51L2070 external address and data memory bus can operate in non-multiplexed mode. this mode is activated by setting the extbuscfg bit of the xmemctrl register to 1. in this case: o d7:d0 will be mapped into port 0 o a7:a0 will be mapped into port 6 o a15:a8 will be mapped into port 2 f igure 6: n on -m ultiplexed e xternal data memory access p2:p6 a[14:0] p2:p6 a[14:0] p0 d[7:0] wr clk non-multiplexed write ce- p0 d[7:0] rd clk non-multiplexed read data ce- 3.8.3 page addressing of the external sram using the mpage register the mpage register provi des access to the entire external memory using indirect addressing through registers r0 and r1. when using the movx @ri instructions, the mpage register provides the upper byte of the address pointed to. t able 19: m emory p age r egister - mpage sfr f1 h 7 6 5 4 3 2 1 0 r/w, reset = 0x00 mpage[7:0] = upper address byte
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 17 of 99 3.9 external bus cs control lines in some applications, the external memory access is only required to perform high speed data transfers between the microcontroller and a parallel access data converter. in this case, only a few register addresses would have to be accessed. the VRS51L2070 provides a feature that great ly simplifies the interface to parallel access peripherals such as data converters or high-speed communication devices. when both the extbuscs bit of the xmemctrl register and the extbusgen bit of the devmemcfg register are set to 1, the VRS51L2070?s external memory bus behaves as follows: ? address lines a15 to a12 operate as cs (chip select) outputs. they are mapped on p2.7- p2.4 ? address lines a11-a8 contain the rest of address ? address lines a0-a7 are mapped into p6 (inaccessible in the 44-pin version of the VRS51L2070) ? port 0 handles the data bus (d7:d0) when the extbuscfg bit is set to 1 (non-multiplexed address/data) ? rd and rw lines on p3.7 and p3.6 are active ? ale is set to 0 the value of bits 13 and 12 of the target address will define the active chip select line output to p2.7-p2.4. address bits 15 and 14 are not taken into account. a11:a0 carries the rest of the address bits. this is represented at the register level as follows: a15 a14 a13 a12 ? a0 x x cs1 cs0 ? as such, when the cs bus control mode is activated, the upper 32kb of the external data memory bus is seen as two overlapping blocks of 16kb. t able 20: e xternal memory bus cs control mode address range i/o pin active as cs 0000h- 7fffh none (4kb sram from 0000h to 0fffh) 8000h-8fffh p2.4-a12 9000h-9fffh p2.5-a13 a000h-afffh p2.6-a14 b000h-bfffh p2.7-a15 c000h-cfffh p2.4-a12 (overlap) d000h-dfffh p2.5-a13 (overlap) e000h-efffh p2.6-a14 (overlap) f000h-ffffh p2.7-a15 (overlap) 4 chip configuration 4.1 VRS51L2070 clo ck configuration the VRS51L2070 clock system is highly configurable. the VRS51L2070 includes an internal 40mhz oscillator, eliminating the need for an external oscillator or crystal. however, an external standard parallel at or bt cut crystal can be used (frequency range of 1mhz to 40mhz). two sfr registers control the configuration of the clock source and the division ratio applied to the system clock source. t he devclkcfg1 register selects either the internal oscillator or the external crystal oscillator as the system clock source. when the oscselect bit is cleared, the VRS51L2070 system clock derives its power from the external crystal oscillator (please see the next section). t able 21:d evice c lock c onfiguration r egister 1 - devclkcfg1 sfr f2 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 1 1 0 0 0 0 0 bit mnemonic description 7 softreset soft reset control bit 6 oscselect oscillator select 0 = external oscillator is selected 1 = internal oscillator is selected 5 clkdiven internal oscillator output clock divisor enable bit 0 = disable clock divisor 1 = enable clock division 4 fullspdint full speed interrupt mode 0 =processor will run with selected clock division during interrupts 1 = processor will run at full speed during interrupts 3:0 clkdiv[3:0] clkdiv value/clock division 0 = /1 1 = /2 2 = /4 3 = /8 4 = /16 5 = /32 6 = /64 7 = /128 8 = /256 9 = /512 a = /1024 b = /2048 c = /4096 d = /8192 e = /16384 f= /32768
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 18 of 99 soft reset operation a software reset can be performed on the VRS51L2070. this is executed via two consecutive instruction: the first instruction is to clear the softreset bit and the second is to set softreset bit to 1: examples of soft reset in asm: anl devclkcfg,#7fh orl devclkcfg,#80h in c : devclkcfg &= 0x7f devclkcfg |= 0x80 the devclkcfg2 register activates the on-chip oscillator and the crystal osc illator. both oscillators can be activated independently, however, as previously mentioned, only one can be used as the VRS51L2070 system clock source. t able 22:d evice c lock c onfiguration r egister 2 - devclkcfg2 sfr f3 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r 0 1 0 0 1 0 0 0 bit mnemonic description 7 cyoscen crystal oscillator enable 0 = crystal oscillator is disabled (default) 1 = crystal oscillator is enabled 6 intoscen internal oscillator enable 0 = internal oscillator is disabled 1 = internal oscillator is enabled (default) 5 - 4 - 3:2 cyrange[1:0] crystal oscillator range 00 = 25mhz ? 40mhz 01 = 4mhz to 25mhz 10 = 32khz to 100khz 11 = 32khz to 100khz 1 reserved 0 systemrdy system ready indicator when this bit is set to 1, it indicates that the VRS51L2070 is no longer driving the reset line the systemrdy bit of the devclkcfg2 register indicates the state of the reset driving circuit. a 0 indicates that the reset line of the VRS51L2070 is driving the rest of the system. the systemrdy bit will be set to 1 by the reset control circuit when the reset line no longer drives the circuit. the crystal oscillator is activated by setting the cyoscen bit of the devclk cfg2 register to 1 and selecting the cyrange value according to the frequency of the crystal used. the cyrange parameter controls the drive of the crystal oscillator circuit. the internal oscillator is activated by setting the intosen bit to 1. before switching from one os cillator source to another, it is important to make su re that both oscillators are active and stable at the moment the transition is made. the minimum period required for the crystal oscillator to stabilize depends on the type of crystal and the frequency used. in general, it is recommended to wait at least 1ms for the crystal oscillator to stabilize before switching to it. the stabilization time of the internal oscillator is much shorter than that of the crystal oscillator. whenever the internal oscillator is reactivated, wait 1ms before switching the system clock back to the internal oscillator. 4.1.1 switching from the internal to the external oscillator the following steps represent the recommended procedure for switching from the internal oscillator to the crystal oscillator: ? activate the crystal oscillator and configure the frequency range, while leaving the internal oscillator active (intoscen = 1) ? wait at least 1ms for stabilization time ? clear the oscselect bit to turn off the internal oscillator below is a code example of the above sequence: ;********************************** ;* switching from internal * ; to external oscillatr * ;********************************** mov devclkcfg2,#11001001b ;enable external crystal osc mov a,#1 ;wait 1ms for crystal to stabilise acall delay1mst0 mov devclkcfg1,#00100000b ;set external crystal oscillator it is important to allow the cr ystal oscillator to stabilize before using it as the system clock. an instable oscillator may result in an operating frequency error or device volatility . 4.1.2 switching from th e external oscillator back to the internal oscillator it is possible to switch system clock source to the internal oscillator while the device is running from the external oscillator. note that before switching the internal oscillator, it must be active. the following the sequence below is recommended in order to switch from the crystal oscillator back to the internal oscillator: o keep the external oscillator enabled (cyoscen = 1), activate the internal oscillator by setting the intoscen bit of the devclkcfg2 register to 1 o wait at least 100 us for stabilization time o set the oscselect bit of the devclkcfg1 register to 1
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 19 of 99 below is a code example of the above sequence: ;********************************** ;* switching from external * ; to internal oscillator * ;********************************** mov devclkcfg2,#11001001b ;reactivate the internal oscillator acall delay100us ;wait 10 0us for self oscillator to stabilize mov devclkcfg1,#01000000b ;set external crystal oscillator 4.1.3 system clock prescaler between the internal and the external oscillator modules and the main system clock tree, the VRS51L2070 includes a clock prescaler module enabling a dynamic division adjustment of the system clock frequency from fosc /1 to fosc/32768. this feature can be useful for saving power in battery- operated applications, in which the device clock speed can be adjusted to suit the processing power requirements. after a reset, the VRS51L2070 will boot up from the internal oscillator and the selected operating speed will be set to 20mhz i.e.. clkdiven is set to 1 and the clkdiv value is 1 (clk = fosc/2). clearing the clkdiven bit will deactivate the main clock prescaler. 4.1.4 interrupt processing speed configuration the VRS51L2070 includes a feature that allows interrupts to be processed at full speed, while the main program executes at a lower speed, as defined by the fullspdint value when the clkdiven bit is set to 1.this mode of operation can be useful for applications where high processing power is required for short periods of time. significant power saving can be achieved by dynamically adjusting the system clock frequency according to the processing power required. 4.2 switching from internal to external oscillator example program /---------------------------------------------------------------------------------------------------------// //VRS51L2070_int_to_ext_to_int_osc_switching_test2-sdcc.c /---------------------------------------------------------------------------------------------------------// // // description: // test switching from internal osc to the external oscillator // then back to the internal oscillator...forever // 1) the program start from the internal oscillator with // duty = 50 / 50 for 100 cycles // 2) then it switch to external oscillator with a // duty of 50/20for 100 cycles // 3) it then switch to internal oscillator // 4) then it execute 100 cycles with a // duty of 20/50 for 100 cycles // 5) return to step 2 //--------------------------------------------------------------------------------------------------------// #include <VRS51L2070_sdcc.h> // --- function prototypes void delay(unsigned int); //----------------------------------------------------------------# / / main function // //----------------------------------------------------------------# void main (void) { int cptr ; periphen1 = 0x01; //enable timer 0 periphen2 = 0x08; //enable ioport p2pincfg = 0x00; //config port 2 as output (for tests) for(cptr =0; cptr < 100; cptr++) //toggle p2 100 times { p2 = 0xff; delay(50); p2 = 0x00; delay(50); }; do{ //-- enable the external oscillator devclkcfg2 = 0xc0; //enable the external oscillator, //keep external osc active //crystal range = 1 to 20mhz delay(10); //stabilization time devclkcfg1 = 0x20; //select external oscillator delay(1); //stabilization time devclkcfg2 = 0x83; //keep the external oscillator, //disable internal osc active for(cptr =0; cptr < 100; cptr++) //toggle p2 100 times { p2 = 0xff; delay(50); p2 = 0x00; delay(20); }; //-- return to the internal oscillator devclkcfg2 = 0xc0; //keep the external oscillator enabled //activate the internal osc //crystal range = 1 to 20mhz
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 20 of 99 delay(100); // stabilization time (way too much) devclkcfg1 = 0x60; //select internal oscillator delay(1); // stabilization time devclkcfg2 = 0x40; //disable the external oscillator, //keep internal osc active for(cptr =0; cptr < 100; cptr++) //toggle p2 100 times { p2 = 0xff; delay(20); p2 = 0x00; delay(50); }; }while(1); }// end of main //--------------------------------------------------------------------------// //--------- individuals functions -------------// //--------------------------------------------------------------------------// //;------------------------------------------------------------------- //;- delay1msto : 1ms delay using timer0 //; calibrated for 40mhz //;------------------------------------------------------------------- void delay(unsigned int dlais){ idata unsigned char x=0; idata unsigned int dlaisloop; x = periphen1; //load periphen1 reg x |= 0x01; //enable timer 0 periphen1 = x; dlaisloop = dlais; while ( dlaisloop > 0) { th0 = 0x63; //timer0 reload value for 1ms at 40mhz tl0 = 0xc0; t0t1clkcfg = 0x00; //no prescaler for timer 0 clock t0con = 0x04; //start timer 0, count up do{ x=t0con; x= x & 0x80; }while(x==0); t0con = 0x00; //stop timer 0 dlaisloop = dlaisloop-1; }//end of while dlais... x = periphen1; //load periphen1 reg x = x & 0xfe; //disableble timer 0 periphen1 = x; }//end of function delais 4.3 processor mode control register the VRS51L2070 provides two power saving modes: idle and power-down, which are controlled by the pdown and idle bits of the pcon register at address 87h. t able 23:p ower contro l r egister - pcon sfr 87 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 1 1 0 0 0 0 0 bit mnemonic description 7 oscstop oscillator stop control when this bit is set to 1, the VRS51L2070 oscillator stops. a reset pulse or a power-on reset is required to restart the device 6 intmoden interrupt module enable 0 = interrupt module is disabled 1 = interrupt module is enabled (default) 5 devcfgen device configuration module enable 0 = device configuration module is disabled 1 = device configuration module is enabled 4 sfrindadr sfr indirect addressing enable 0 = nop instruction a5h behaves normally 1 = nop instruction a5h acts as a sfr indirect addressing instruction 3 gf1 general purpose flag 2 gf0 general purpose flag 1 pdown power-down mode enable when this bit is set to 1, the processor goes into power-down mode. a reset is required to exit power-down mode 0 idle idle mode enable when this bit is set to 1, the processor goes into power-idle mode. a reset or an interrupt is required to exit idle mode 4.3.1 oscillator stop mode the oscillator stop mode goes one step further than the pdown mode. when the oscstop bit is set, all the oscillators are stopped, achieving maximum power saving, while maintaining the i/os in their current state. note that in this mode, the watchdog timer will stop functioning. in order to stop the oscillator of the VRS51L2070, clear the oscstop bit of the pcon register and then immediately set it to 1, as shown below: pcon &= 0x7f pcon |= 0x80 4.3.2 sfr indirect addressing capability the sfr registers on the VRS51L2070 can be accessed via indirect addressi ng. this is accomplished by setting the sfrindadr bit of the pcon register. when sfrindadr is set, the a5h instruction functions as an sfr indirect addressing instruction (the default at reset is the nop instruction).
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 21 of 99 4.3.3 pdown and idle power saving mode in idle mode, the processor clock is stopped, however the peripherals remain active. the contents of the sram, the state of the i/os and the sfr registers are maintained, as are the timer, external interrupt and uart operations. idle mode is useful for applications in which stopping the processor to save power is required. the processor will be activated when an external event, triggering an interrupt, occurs. in power-down mode, the VRS51L2070 oscillator is stopped. while the clock to all the peripherals is deactivated, the contents of the sram and the sfr registers is maintained. the only way to exit power- down mode is via a hardware reset. in power-down and idle modes the watchdog timer continues to function. VRS51L2070 peripheral enable 4.4 peripherals enable register the VRS51L2070 peripherals can be individually activated. the periphen1 and periphen2 registers are used for this purpose. with the exception of the i/o ports, all the VRS51L2070 peripherals and communication interfaces are in the disable state upon reset. when a given peripheral is inactive, read and write operations to its sfr registers will have no effect. to activate a given peripheral, the corresponding enable bit in the periphenx registers must be set to 1. the periphen1 register controls the activation of the: ? spi interface ? i2c interface ? two uarts ? timers t able 24: p eripheral e nable r egister 1 - periphen1 sfr f4h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 spicsen enable spi cs line 0 = spi cs lines are disabled (accessible as i/o) 1 = spi cs lines are enabled and reserved by spi interface 6 spien spi interface enable 0 = spi interface is disabled 1 = spi interface is enabled 5 i2cen i2c interface enable 0 = i2c interface is disabled 1 = i2c interface is enabled 4 u1en uart1 interface enable 0 = uart1 interface is disabled 1 = uart1 interface is enabled 3 u0en uart0 interface enable 0 = uart0 interface is disabled 1 = uart0 interface is enabled 2 t2en timer2 enable 0 = timer 2 interface is disabled 1 = timer 2 interface is enabled 1 t1en timer1 enable 0 = timer 1 interface is disabled 1 = timer 1 interface is enabled 0 t0en timer0 enable 0 = timer 0 interface is disabled 1 = timer 0 interface is enabled when the spi interface is enabled, the spi cs0 line is reserved for the spi interface, independent of the state of the spicsen bit. uart1 has priority over the spicsen bit of the periphen1 register. as such, even if the spi cs1, cs2 and cs3 lines are activated by setting the spicsen bit to 1, when uart 1 is used, it will override cs2 and cs3.
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 22 of 99 additionally, when activated, the spi interface, has priority over the timer 2 input, even if timer 2 is enabled. the periphen2 register controls the activation of the: ? pulse width counter modules ? arithmetic unit ? i/o ports ? watchdog timer ? fpi interface it also activates the xram into code mode, in which the processor starts exec uting code from the 4kb block of externally mapped sram memory. t able 25: p eriphera 2 e nable r egister 2 - periphen2 sfr f5h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 1 0 0 0 bit mnemonic description 7 pwc1en pulse width counter 1 enable 0 = pwc1 is off 1 = pwc1 is on 6 pwc0en pulse width counter 0 enable 0 = pwc0 is off 1 = pwc0 is on 5 auen arithmetic unit enable 0 = arithmetic unit is off 1 = arithmetic unit is on 4 xram2code when set to 1, the 4kb block of sram is mapped into the program code area from 0000h to 3fffh. xram-based variable are not permitted when the processor is running from the xram. the xram2code bit must be set and cleared only when the program counter is outside the abovementioned address range. 3 ioporten i/o port enable 0 = i/o ports are deactivated 1 = i/o ports are activated 2 wdten watchdog timer module enable 0 = wdt is off 1 = wdt is on 1 pwrsfren pulse width modulators sfr enable 0 = sfr associated with pwms are deactivated 1 = sfr associated with pwms are activated 0 fpien fpi interface enable 0 = fpi interface is disabled 1 = fpi interface is enabled 4.5 peripheral i/o mapping and priority the pin locations of the following peripherals can be remapped to alternate pin positions: o timer 2 output o i2c o uart0 o uart1 o pwms this feature has been included to provide access to all peripherals. the following table lists the peripherals whose i/o positions are configurable: t able 26:p eripheral a lternate p in configuration peripheral default pin alternate pin t2out p1.2 p4.4 t2ex p1.1 p6.0 t2in p1.0 p6.1 scl p3.4 p1.6 sda p3.5 p1.7 rxd0 p3.0 p2.4 txd0 p3.1 p2.3 rxd1 p1.2 pin 41 txd1 p1.3 pin 40 pwm[7:0] p2[7:0] p5[7:0]
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 23 of 99 5 input/output ports the VRS51L2070 includes 56 i/o pins grouped into seven ports. all the VRS51L2070 i/os are 5v-tolerant, except for p4.6 and p4.7, which can endure a maximum input voltage of vdd+0.5v. 5.1 structure of the i/o ports all i/o ports on the VRS51L2070 have the same structure. their main difference resides in the drive capability of the i/o ports, as shown in the following diagram: f igure 7: g eneral s tructure of the VRS51L2070 i/o s ic pin oen input output provide 5v toltrance w hen i/o is configured as input it will be pulled up at 2.5v instead of 3.3v when the i/o ports are configured as inputs, the pin is pulled high to a voltage of about 2.50v, instead of the device voltage, which is 3.3v. an external pull-up resistor can be added to pull the i/o pin up to 3.3 volts or to 5 volts. 5.2 direction confi guration registers for the i/o ports each i/o port on the VRS51L2070 has dedicated sfr registers for read/write operations and for i/o pin direction. the pin direction configuration registers allow the user to configure the di rection of each individual i/o pin. writing a 1 to these register bit positions configures the corresponding i/o port as an input. to configure an i/o pin as an output, the corresponding bit in the pin direction configuration register must be cleared. because the pin direction configuration registers are not located at addresses that are multiples of x0h or x8h, they are not bit-address able. when a peripheral is activated, it takes control of the i/o pins and the i/o pin direction is configured automatically. the user can monitor the activity of any peripheral module input pin current state by configuring the corresponding i/o pin as an input and reading the port pin value. t able 27:p ort 0 pin direction config uration register - p 0 pincfg -sfr f9 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 1 1 1 1 1 1 1 1 bit mnemonic description 7 p07in1out0 when: 1 = i/o pin acts as a input (reset value) 0 = i/o pin acts as a output 6 p06in1out0 same as bit 7 5 p05in1out0 same as bit 7 4 p04in1out0 same as bit 7 3 p03in1out0 same as bit 7 2 p02in1out0 same as bit 7 1 p01in1out0 same as bit 7 0 p00in1out0 same as bit 7 when the external data memory bus access is activated, port 0 functions as d7:d0 and/or address a7:a0. t able 28:p ort 1 pin direction config uration register - p 1 pincfg -sfr fa h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 1 1 1 1 1 1 1 1 bit mnemonic description 7 p17in1out0 1 = i/o pin act as a input (reset value) 0 = i/o pin act as a output 6 p16in1out0 same as bit 7 5 p15in1out0 same as bit 7 4 p14in1out0 same as bit 7 3 p13in1out0 same as bit 7 2 p12in1out0 same as bit 7 1 p11in1out0 same as bit 7 0 p10in1out0 same as bit 7 t able 29:p ort 2 pin direction config uration register - p 2 pincfg -sfr fb h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 1 1 1 1 1 1 1 1 bit mnemonic description 7 p27in1out0 when: 1 = i/o pin acts as a input (reset value) 0 = i/o pin act as a output 6 p26in1out0 same as bit 7 5 p25in1out0 same as bit 7 4 p24in1out0 same as bit 7 3 p23in1out0 same as bit 7 2 p22in1out0 same as bit 7 1 p21in1out0 same as bit 7 0 p20in1out0 same as bit 7 when the external data memory bus is activated, except when in external bus cs mode, port 2 functions as address bus bits a15:a8.
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 24 of 99 t able 30:p ort 3 pin direction config uration register - p 3 pincfg -sfr f ch 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 1 1 1 1 1 1 1 1 bit mnemonic description 7 p37in1out0 when: 1 = i/o pin act as a input (reset value) 0 = i/o pin act as a output 6 p36in1out0 same as bit 7 5 p35in1out0 same as bit 7 4 p34in1out0 same as bit 7 3 p33in1out0 same as bit 7 2 p32in1out0 same as bit 7 1 p31in1out0 same as bit 7 0 p30in1out0 same as bit 7 when the external data memory bus is activated, p3.6 and p3.7 function as wr and rd. t able 31:p ort 4 pin direction config uration register - p 4 pincfg -sfr fd h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 1 1 1 1 1 1 1 1 bit mnemonic description 7 p47in1out0 when: 1 = i/o pin acts as a input (reset value) 0 = i/o pin acts as a output 6 p46in1out0 same as bit 7 5 p45in1out0 same as bit 7 4 p44in1out0 same as bit 7 3 p43in1out0 same as bit 7 2 p42in1out0 same as bit 7 1 p41in1out0 same as bit 7 0 p40in1out0 same as bit 7 t able 32:p ort 5 pin direction config uration register - p 5 pincfg -sfr fe h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 1 1 1 1 1 1 1 1 bit mnemonic description 7 p57in1out0 when: 1 = i/o pin acts as a input (reset value) 0 = i/o pin acts as a output 6 p56in1out0 same as bit 7 5 p55in1out0 same as bit 7 4 p54in1out0 same as bit 7 3 p53in1out0 same as bit 7 2 p52in1out0 same as bit 7 1 p51in1out0 same as bit 7 0 p50in1out0 same as bit 7 t able 33:p ort 6 pin direction config uration register - p 6 pincfg -sfr ff h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 1 1 1 1 1 1 1 1 bit mnemonic description 7 p67in1out0 when: 1 = i/o pin acts as a input (reset value) 0 = i/o pin acts as a output 6 p66in1out0 same as bit 7 5 p65in1out0 same as bit 7 4 p64in1out0 same as bit 7 3 p63in1out0 same as bit 7 2 p62in1out0 same as bit 7 1 p61in1out0 same as bit 7 0 p60in1out0 same as bit 7 5.3 i/o ports input enable register upon reset, all the VRS51L2070 i/os are configured as inputs and the input control logic of all ports is activated. a given i/o port?s input logic can be deactivated by clearing the corresponding bit in the portinen register. t able 34:p orts i nput e nable register - portinen sfr f7 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 1 1 1 1 1 1 1 1 bit mnemonic description 7 reserved (0) keep this bit at 0 6 p6inputen port 6 input enable register 0 = port 6 input logic is deactivated 1 = port 6 input logic is activated 5 p5inputen port 5 input enable register 0 = port 5 input logic is deactivated 1 = port 5 input logic is activated 4 p4inputen port 4 input enable register 0 = port 4 input logic is deactivated 1 = port 4 input logic is activated 3 p3inputen port 3 input enable register 0 = port 3 input logic is deactivated 1 = port 3 input logic is activated 2 p2inputen port 2 input enable register 0 = port 2 input logic is deactivated 1 = port 2 input logic is activated 1 p1inputen port 1 input enable register 0 = port 1 input logic is deactivated 1 = port 1 input logic is activated 0 p0inputen port 0 input enable register 0 = port 0 input logic is deactivated 1 = port 0 input logic is activated 5.4 i/o ports sfr registers as is the case for standard 8051 devices, the i/o ports on the VRS51L2070 are mapped into sfr registers that are bit-addressable. at reset, the i/o ports are activated and configured as inputs. the VRS51L2070 i/o output drivers, unlike the original standard 8051 i/o output driv ers, are of the push-pull type. the VRS51L2070 i/os have the same output drive capability whether they are driving a logic high or a logic low, versus the st andard 8051s, which feature an active low driver with a pull-up resistor. from a software point of view, the difference is that whenever the configuration of a given i/o has to be changed, the corresponding bit in the port direction configuration register must be set accordingly.
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 25 of 99 the following tables describe the sfr registers associated with the VRS51L2070 i/o ports. t able 35:p ort 0 register - p0 sfr 80 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 1 1 1 1 1 1 1 1 bit mnemonic description 7:0 p0[7 :0] port 0 t able 36:p ort 1 register - p1 sfr 90 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 1 1 1 1 1 1 1 1 bit mnemonic description 7:0 p1[7 :0] port 1 t able 37:p ort 2 register - p2 sfr a0 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 1 1 1 1 1 1 1 1 bit mnemonic description 7:0 p2[7 :0] port 2 t able 38:p ort 3 register - p0 sfr b0 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 1 1 1 1 1 1 1 1 bit mnemonic description 7:0 p3[7 :0] port 3 t able 39:p ort 4 register - p4 sfr c0 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 1 1 1 1 1 1 1 1 bit mnemonic description 7:0 p4[7 :0] port 4 t able 40:p ort 5 register - p5 sfr 98 h (VRS51L2070-64 pin only ) 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 1 1 1 1 1 1 1 1 bit mnemonic description 7:0 p5[7 :0] port 5 t able 41:p ort 6 register - p6 sfr c8 h (VRS51L2070-64 pin only ) 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 1 1 1 1 1 1 1 1 bit mnemonic description 7:0 p6[7 :0] port 5 5.5 i/o port drive capability the current drive capability of the VRS51L2070 i/o ports is not the same for all ports. most can drive 2ma and others can drive more in either current source or current sink and can be used for direct led drive. the following table summarizes the VRS51L2070 i/o port drive capabilities: t able 42:i/o p orts driving capability i/o port max current on individual pin port 0[7:0] 2ma port 1[7:5] port 1[4:0] 4ma 2ma port 2[7:0] 8ma port 3[7:6] port 3[5:4] port 3[3:0] 2ma 4ma 2ma port 4[7:0] 2ma port 5[7:0] 16ma port 6[7:0] 2ma it is not recommended to exceed the sink current specified in the table above. doing so will likely cause the low-level output voltage to exceed device specifications and affect device reliability. for the current revision of the VRS51L2070, the total dc load on the i/o ports should not exceed 100ma. 5.6 port software specifics some instructions allow the user to read the logic state of the output pin, while others allow the user to read the contents of the associated port register. these instructions are called read-modify-write instructions. a list of these instructions may be found in the following table. upon executing these instru ctions, the content of the port register (at least 1 bit) is modified. the other read instructions take the present state of the input into account. for example, instruction anl p3,#01h obtains the value in the p3 register; performs the desired logic operation with the constant 01h and recopies the result into the p3 register. in order to monitor the present state of the inputs of an i/o port bit, first, read the port, and second, perform an and or an or operation, as required by the program: mov a, p3; state of the inputs in the accumulator anl a, #01; and operation between p3 and 01h
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 26 of 99 when the port is used as an output, the register contains information on t he state of the output pins. measuring the state of an out put directly on the pin is inaccurate because the voltage level depends mostly on the type of charge that is applied to it. the functions below perform the operation on the value of the port register rather than the actual port pin itself. t able 43: l ist of i nstructions that r ead and m odify the p ort u sing r egister v alues instruction function anl logical and ex: anl p0, a orl logical or ex: orl p2, #01110000b xrl exclusive or ex: xrl p1, a jbc jump if the bit of the port is set to 0 cpl complement 1 bit of the port inc increment the port register by 1 dec decrement the port register by 1 djnz decrement by 1 and jump if the result is not equal to 0 mov p.,c copy the held bit c to the port clr* p.x set the port bit to 0 setb p.x set the port bit to 1 * note : even though the cpu does not read in this case, it is considered a read-modify-write instruction. in mov dir, dir has an extra cycle when doing an sfr read during a debugger interrupt. the debugger memory is synchronous and is mapped into the sfr bus and, therefore, require s an extra read cycle. instruction a5, which is considered an nop in a standard 8051, has been redefined to perform write and read sfr indirect addressing. therefore, during a debugger interrupt, the a5 indirect read sfr addressing requires an extra cycle. 5.7 port operation timing 5.7.1 writing to a port (output) 5.7.2 reading a port (input) 5.8 i/o port example programs 5.8.1 i/o ports toggle example this program shows the activation and configuration of ports p0 to p4 as outputs. the program continuously toggles their values. ;************************************************* ;* VRS51L2070 i/o ports toggle example * ;************************************************* start: mov periphen2,#08h ;enable io mov p0pincfg,#00h ;configure p0 as output mov p1pincfg,#00h ;configure p1 as output mov p2pincfg,#00h ;configure p2 as output mov p3pincfg,#00h ;configure p3 as output mov p4pincfg,#00h ;configure p4 as output mov periphen2,#00001000b ;bit7 - pwc1en ;bit6 - pwc0en ;bit5 - auen ;bit4 - xram2code ;bit3 - ioporten ;bit2 - wdten ;bit1 - pwmsfren ;bit0 - fpien // i/o output toggle loop loop: mov p0,#00h ;force p0 = 00h mov p1,#00h ;force p1 = 00h mov p2,#00h ;force p2 = 00h mov p3,#00h ;force p3 = 00h mov p4,#00h ;force p4 = 00h mov a,#100 ;wait 100ms using timer 0 acall delay1mst0 ;see timer section mov p0,#0ffh ;force p0 = ffh mov p1,#0ffh ;force p1 = ffh mov p2,#0ffh ;force p2 = ffh mov p3,#0ffh ;force p3 = ffh mov p4,#0ffh ;forc e p4 = ffh mov a,#100 ;wait 100ms using timer0 acall delay1mst0 ;see timer section ljmp loop the delay1ms function is described in the timers section.
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 27 of 99 5.8.2 i/o port read example ;************************************************************** ;* VRS51L2070 i/o ports read and write example * ;*************************************************************** portread equ 021h ;genreal variable start: mov periphen2,#08h ;enable io mov p0pincfg,#00h ;configure p0 as intput mov p1pincfg,#00h ;configure p2 as output ; note that the port input logic is activated by default mov periphen2,#00001000b ;bit7 - pwc1en ;bit6 - pwc0en ;bit5 - auen ;bit4 - xram2code ;bit3 - ioporten ;bit2 - wdten ;bit1 - pwmsfren ;bit0 - fpien ;*** read port 0 and copy the value to p2 loop: mov portread, p0 ;read prt 0 and store the value in a variable mov p2, portread ;write the variable content to p2 ajmp loop in this example, the port p0 value is stored in a variable before writing it to p2, but the user can also directly transfer p0 to p2 in one operation: loop: mov p2,p0 ;would do the same operation more efficiently ajmp loop 5.9 port pin change monitoring the VRS51L2070 includes an i/o port pin change monitoring subsystem. this module is used to monitor the activity on the selected i/o ports. when enabled, if a pin state changes on the selected i/o port, the pmonflag will be set to 1 by the system. it must be cleared manually by the software. the port pin change monitoring feature is very useful for monitoring events that can occur on a given group of i/os without having to constantly read the i/o state. since it is connected to the VRS51L2070 interrupt subsystem, the port pin change monitoring system frees the processor resources for other tasks. t able 44:p ort c hange m onitoring register - portchg sfr b9 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 pmonflag1 port change monitoring flag1 when set, monitored port state has changed 6 pchgmsk1 port change mask register 1 0 = port monitoring is deactivated 1 = port monitoring is activated 5:4 pchgsel1[1:0] port change monitoring register select 1 00 = p4 change is monitored 01 = p5 change is monitored 10 = p6 change is monitored 11 = p4[3:0] change is monitored 3 pmonflag0 port change monitoring flag 0 when set, monitored port state has changed 1 pchgmsk0 port change mask register 0 0 = port monitoring is deactivated 1 = port monitoring is activated 1:0 pchgsel0[1:0] port change monitoring register select 0 00 = p0 change is monitored 01 = p1 change is monitored 10 = p2 change is monitored 11 = p3 change is monitored the port pin change monitoring flags, pmonflagx, are active at all times, even if the port change masks are not activated. the pchgmskx bits serve to connect the port change module to the VRS51L2070 interrupt system. the port change monitoring flags must be cleared manually.
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 28 of 99 5.10 port pin change interrupt example programs 5.10.1 numeric keypad interface //--------------------------------------------------------------------------------------------------------------------// // VRS51L2070_keypadp0_lcdp1.c // //--------------------------------------------------------------------------------------------------------------------// // // description: character lcd and numeric keypad interface example program. // // this program initialize and sends lcd strings and numeric values // to a character based lcd display. // the program also demonstrate the use of the port change interrupt // feature of the VRS51L2070 to simplify the interface with a numeric keypad // on port 0. // the numeric keypad is a standard phone keypad which to connected to port 0 // as shown below: // column 3 - p0.7 // column 2 - p0.6 // column 1 - p0.5 // row 4 - p0.3 // row 3 - p0.2 // row 2 - p0.1 // row 1 - p0.0 // // no external pull-up / pull down resistors are required, thank to the // presence of internal pull-up on the VRS51L2070 i/o ports. // // the interface to the lcd done through the VRS51L2070 port 1. // the lcd is initialized to operate in 4 bit data bus mode // // lcd interface structure: // ======================== // p1.0 = lcd rs // p1.1 = lcd rw // p1.2 = lcd e // p1.3 = (not used) // p1[7:4] = lcd data (4 bit mode) // // notes about standard character lcd display interface to the VRS51L2070 // -most lcd displays operates on a 4.5v to 5.5v supply. // they won't work with the 3.3v supply the VRS51L2070 operate from // -on the digital side make sure the lcd module logic high level lower limit // is below 3v. // -the VRS51L2070 i/os are 5v tolerant, so there is no need to add interface // circuit between the lcd module's i/o and the VRS51L2070 i/o // // // //--------------------------------------------------------------------------------------------------------------------// // target: VRS51L2070 //--------------------------------------------------------------------------------------------------------------------// // // rev 1.0 // date: june 2005 //--------------------------------------------------------------------------------------------------------------------// #include <VRS51L2070_sdcc.h> //--lcd i/o definition #define lcdport p1 #define lcdportdir p1pincfg //--keypad i/o definition #define keypadport p0 #define keypadportdir p0pincfg //---keypad functi on prototypes char keydecode(); void keydisplay(char); //---lcd function prototypes void lcdbusy(void); //lcd busy check void initlcd(void); //lcd initialisation function void lcdslow(void); //slow down communication with lcd display void int2lcd(unsigned int); //integer to lcd display function void lcdstring( char code *); //string to lcd display function void sendlcdchar( char); //char to lcd display function void sendlcdcmd( unsigned char); //send lcd command function //---generic functions prototype void v2kdelay1ms(unsigned int); //standard delay function // lcd bit variables bit at 0x92 lcd_e; //lcd e line bit at 0x90 lcd_rs; //lcd rs bit at 0x91 lcd_rw; //lcd rw // global variables definitions idata unsigned char cptr = 0x00; // lcd strings and constants definitions code char msg1[]= "VRS51L2070 \0"; code char msg2[]= "waiting for key.\0"; code char msgkey[]= "last key: \0"; code char lcd_l1c1 = 0x80; //command lcd set cgram addr to line1,column 1 code char lcd_l2c1 = 0xc0; //command lcd set cgram addr to line2,column 1 code char lcd_l2c10 = 0xc9; //command lcd set cgram addr to line2,column 10 code char lcd_clear = 0x01; //command lcd clear and return cursor home //--------------------------------------------------------------------------------------------------------------------// // main function //--------------------------------------------------------------------------------------------------------------------// void main (void) { periphen1 = 0x01; //enable timer 0 lcdportdir = 0x00; //config lcd port as output //--configure keypad port and port change monitor keypadportdir = 0x0f; //keypadport bit 3:0 -> configured as input (lines) //keypadport bit 7:5->configured as output (columns) keypadport = 0x0f; //clear the columns driver outputs v2kdelay1ms(100); //put a 100 milliseconds delay portchg = 0x04; //disable port change monitoring module 1 //enable port change monitoring module 0 //clear the port change monitoring flag //port 0 change is monitored //-- activate port change interrupt intsrc1 &= 0xef; //force interrupt vector 4 to be routed to port change //module 0 inten1 |= 0x10; //enable the port change 0 module interrupt geninten = 0x01; //activate the global interrupts //--initialize the lcd initlcd(); //initialise the lcd module sendlcdcmd(lcd_l1c1); //place lcd cursor on line 1, column 1 cptr = 0; while( msg1[cptr] != '\0') //display "VRS51L2070" on first line of lcd display sendlcdchar( msg1[cptr++]); sendlcdcmd(lcd_l2c1); //place lcd cursor on line 2, column 1 cptr = 0; while( msg2[cptr] != '\0') //displ ay "waiting for key.\0" on 2 line of lcd display sendlcdchar( msg2[cptr++]); v2kdelay1ms(1000); //put a 1 seconds delay //--loop waiting for keys to be pressed while(1); //infinite loop }// end of main //----------------------------------------------------------------------------------------// //----------------------port change interrupt function(s)---------------------// //----------------------------------------------------------------------------------------// void portchange0int(void) interrupt 4 { unsigned char keypressed = 0x00; //var holding ascii value of the last key //pressed (could be global) unsigned char keylines = 0x00; //variable to read the actual i/o port unsigned char keyrow = 0x00; //row position of the pressed key unsigned char keycol = 0x00; //column position of the pressed key // rows and columns association table const char code keyrowmap[] = {0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x03,0x0f,0x0f,0x0f,0x02,0x0f,0x01,0x00,0x0f}; const char code keycolmap[]={0x0f,0x0f,0x0f,0x02,0x0f,0x01,0x00,0x0f}; // ascii code associated with pressed key const char code keyascii[4][3] = { {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'}}; geninten = 0x00; //disable the global interrupts //--retrieve the line number keypadport = 0x00; //send 0 on each column
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 29 of 99 v2kdelay1ms(10); //put a 10 millisecond delay keylines = keypadport; //read keypad port keylines &=0x0f; //isolate lower nibble if(keylines != 0x0f) { //-retrieve the line value keyrow = keyrowmap[keylines]; //--retrieve column number keypadportdir = 0xf0; //columns are input / rows are output keypadport = 0x00; //send 0 on each row v2kdelay1ms(10); //put a 10 millisecond delay keylines = keypadport; //read keypad port b = keylines; keylines &=0xe0; //isolate upper 3 bit (columns) keylines = (keylines >> 5); //position columns to lower portion //-retrieve the line value keycol = keycolmap[keylines]; if((keyrow != 0x0f)&& (keycol != 0xff)) { //--get the ascii value of the key keypressed = keyascii[keyrow][keycol]; sendlcdcmd(lcd_l2c1); /place lcd cursor on line 2, column 1 cptr = 0; while( msgkey[cptr] != '\0') //display "last key: \0" sendlcdchar( msgkey[cptr++]) //on second line of lcd display //display the key value on the lcd display sendlcdcmd(lcd_l2c10); //place lcd cursor on line 2, column 10 sendlcdchar(keypressed); }//end of if key row / col //--wait for the key to be released do{ b= keypadport; b &= 0xe0; }while(b != 0xe0 ); //--set keypadport as before keypadportdir = 0x0f; //columns are input / rows are output keypadport = 0x0f; //clear the columns driver outputs v2kdelay1ms(10); // put a 10 millisecond delay }//end of if keylines != 0xff portchg = 0x04; //disable port change monitoring module 1 //enable port change monitoring module 0 //clear the port change monitoring flag //port 0 change is monitored geninten = 0x01; //activate the global interrupts }//end of port change interrupt //--------------------------------------------------------------------------------------------------------------------// // individuals functions //--------------------------------------------------------------------------------------------------------------------// (see demonstration programs? ) 6 VRS51L2070 timers the VRS51L2070 includes three 16-bit timers: timer 0, timer 1 and timer 2. the VRS51L2070 timers include more functionality and features than standard 8051 timers: o timers 0, 1 can operate as one 16-bit timer or two 8-bit timers o timers can count up/count down o each timer includes a configurable divisor o timers can be chained together to form 24-, 32- or 48-bit timer/counters o each timer features an output that can generate a pulse or toggle when the timer overflows o each timer provides counter input o each timer provides a gating pin VRS51L2070 timers include a number of parameters that can be adjusted independently, enabling countless configurations to suit a diversity of timing/counting applications. the structure of the timer configuration registers has been simplified compared to standard 8051 timer control registers. the architecture of the registers controlling the VRS51L2070?s three timers is the same for timer 0 and timer 1 and almost the same for timer 2. 6.1 timer 0, timer 1 configuration timer 0 and timer 1 operation is controlled by three registers. the configuration of timers 0/1 is essentially the same. 6.1.1 t0t1cfg register overview the t0t1cfg register controls the gating features of both timer 1 and timer 0. the txgate bit controls the clock gating of the timers. when this bit is set to 1, the timer will only count when the intx pin is high.
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 30 of 99 t able 45: t imer 0 / t imer 1 c onfiguration register - t0t1cfg sfr 89 h 7 6 5 4 3 2 1 0 r r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 - not used 6 t1gate timer 1 gating enable 0 = timer 1 gating feature is disabled 1 = timer 1 count only when int1 pin is high 5 t0gate timer 0 gating enable 0 = timer 0 gating feature is disabled 1 = timer 0 count only when int0 pin is high 4 t1clksrc timer 1 clock source 0 = timer 1 takes its clock from system clock 1 = timer 1 takes its clock from timer 0 output 3 t1outen timer 1 output enable 0 = timer 1 output is deactivated 1 = timer 1 output is connected to a pin 2 t1mode8 timer 1 8-bit operating mode enable 0 = timer 1 operates as a 16-bit timer 1 = timer 1 operates as two 8-bit timers 1 t0outen timer 0 output enable 0 = timer 0 output is deactivated 1 = timer 0 output is connected to a pin 0 t0mode8 timer 1 8-bit operating mode enable 0 = timer 1 operates as a 16-bit timer 1 = timer 1 operates as two 8-bit timers the t1clksrc bit defines which clock source will feed timer 1 when it is configured to operate in timer mode. the timer 1 clock source is defined as follows: o t1clksrc = 0 system clock o t1clksrc = 1 timer 0 output (overflow) when configured in timer mode, timer 0 can only derive its clock source from the system clock with the proper prescaler value. both timers 1 and 0 can operate as two general purpose 8-bit timers. this mode is activated by setting the corresponding txmode 8 bit of the t0t1cfg register to 1. t able 46:t imer 0 / t imer 1 c lock c onfig . r egister - t0t1clkcfg sfr 99 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:4 t1clkcfg[3:0] timer 1 clock prescaler configuration see table below 3:0 t0clkcfg[3:0 timer 0 clock prescaler configuration see table below t able 47:t imer 0 / t imer 1 c lock division ratio t0/1clkcfg (4 bit binary) timer clock div. ratio t0/1clkcfg timer clock div. ratio 0000 1 1000 256 0001 2 1001 512 0010 4 1010 1024 0011 8 1011 2048 0100 16 1100 4096 0101 32 1101 8192 0110 64 1110 16384 0111 128 1111 16384 6.1.2 the t0con and t1con registers the t0con and t1con sfr registers control the following: o timer operation mode (timer or counter) o advanced gating features of timer 0 and timer 1 o timer overflow flag o counting direction (up/down) o timer reload and capture o timer output mode (pulse/toggle) these registers are fully orthogonal, which means that for a given timer operating mode, the registers function in the same manner. t able 48:t imer 0 c onfiguration register - t0con sfr 9a h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 t0ovf timer 0 overflow flag set to 1 when timer overflow from ffffh to 0000h. must be cleared by software. writing 1 into this bit will trigger a timer interrupt, if enabled 6 t0exf timer 0 external flag gating flag set to 1 when timer reload of capture is caused by an high to low transition on the t0ex pin, if t0exen is set to 1 5 t0downen timer 0 count down enable 0 = timer 0 count up 1 = timer 0 counts down 4 t0togout timer 0 output toggle enable 0 = timer 0 output outputs a pulse when it overflow from ffffh to 0000h 1 = timer 0 output toggle when it overflow from ffffh to 0000h 3 t0exten timer 0 external gating enable 0 = t0ex pin is not active 1 = enable timer 0 capture or reload upon a high to low transition on the t0ex pin 2 tr0 timer 0 run 0 = timer 0 is stopped 1 = timer 0 is running 1 t0counten timer 0 counter enable 0 = timer 0 acts as a timer 1 = timer 0 acts as a counter that is incremented (decremented) by a high to low transition on t0in pin 0 t0rlcap timer 0 capture enable 0 = auto reload value is loaded in timer 0, if a high to low transition occurs on t0ex, if t0exten is set to 1 1 = timer 0 current value is captured when a high to low transition occurs on the t0ex pin, if t0exten is set to 1
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 31 of 99 t able 49:t imer 1 c onfiguration register - t1con sfr 9b h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 t1ovf timer 1 overflow flag get set to 1 when timer overflow from ffffh to 0000h. must be cleared by software. writing 1 into this bit will trigger a timer interrupt, if enabled 6 t1exf timer 1 external flag gating flag get set to 1 when timer reload of capture is caused by an high to low transition on the t1ex pin, if t1exen is set to 1 5 t1downen timer 1 count down enable 0 = timer 1 count up 1 = timer 1 counts down 4 t1togout timer 1 output toggle enable 0 = timer 1 output outputs a pulse when it overflow from ffffh to 0000h 1 = timer 1 output toggle when it overflow from ffffh to 0000h 3 t1exten timer 1 external gating enable 0 = t1ex pin is not active 1 = enable timer 1 capture or reload upon a high to low transition on the t1ex pin 2 tr1 timer1 run 0 = timer 1 is stopped 1 = timer 1 is running 1 t1counten timer 1 counter enable 0 = timer 1 acts as a timer 1 = timer 1 acts as a counter that is incremented (decremented) by a high to low transition on t1in pin 0 t1rlcap timer 1 capture enable 0 = auto reload value is loaded in timer 1, if a high to low transition occurs on t1ex, if t1exten is set to 1 1 = timer 1 current value is captured when a high to low transition occurs on the t1ex pin, if t1exten is set to 1. the txovf bit of the txcon re gister indicates that the timer count has rolled over from ffffh to 0000h. if the corresponding timer interrupt has been enabled, the txovf will raise the interrupt. the txexf flags are set to 1 when a high to low transition occurs on the corresponding txex pin, provided that the txexen pin is set to 1. timer 0 and timer 1 can count up or down. by default, the timers count up. however setting the txdownen bit to 1 will make the timer count down . the txcounten bit allows the timer to be configured as an external event counter. by default, the timers derive their source from the system clock or a prescaled source. setting the txcounten bit to 1, will configure the corresponding timer to derive its source from the timer input pin (txin). a high to low transition on the timer input pin will make the timer count one step up or one step down, depending on the value of the corresponding txdownen bit. the txrlcap bit defines the function of the timer capture/reload register upon a high to low transition on the txex timer trigger input pin. o txrlcap = 0 : auto reload value is loaded in timer x o txrlcap = 1 : timer x current value will be captured the functions associated with the txrlcap bit are only activated when the corresponding txexten bit is set to 1. 6.2 timer 0 and timer 1 current value register two sfr registers provide access to the current 16-bit value of timer 0 and timer 1. t able 50:t imer 0 l ow - tl0 sfr 8a h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 tl0[7:0] t able 51:t imer 0 h igh - th0 sfr 8b h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 th0[7:0] t able 52:t imer 1 l ow - tl1 sfr 8c h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 tl1[7:0] t able 53:t imer 1 h igh - th0 sfr 8d h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 th0[7:0]
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 32 of 99 6.2.1 timer 0 reload and capture registers both timer 0 and timer 1 have an auxiliary 16-bit reload/capture register, which is accessible through two sfr registers as follows: t able 54:t imer 0 r eload and c apture l ow - rcap0l sfr 92 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 rcap0l[7:0] t able 55:t imer 0 r eload and c apture h igh - rcap0h sfr 93 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 rcap0h[7:0] t able 56:t imer 1 r eload and c apture l ow ? rcap1l sfr 94 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 rcap1l[7:0] t able 57:t imer 1 r eload and c apture h igh ? rcap1h sfr 95 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 rcap1h[7:0] 6.2.2 timer 0/1 output timer 0 and timer 1 outputs can be routed to an external pin. this feature is activated by setting the txouten bit of the txclkcfg register to 1. by default, the timer outputs, wh en enabled, will generate a pulse upon timer overflow. the duration of the pulse equals 1/ sys clk. setting the txtogout bit of the txcon register to 1 will configure the timer x output to toggle upon a timer overflow instead of generating a pulse. f igure 8: t imer 0, t imer 1 o utput modes timer 0/1 overflow txouten = 1 txtogout = 1 txouten = 1 txtogout = 0 6.3 timer 0/1 alternate mapping bits 0 and 1 of the deviomap register (sfr e1h) control the mapping of the timer 0 and timer 1 peripherals as shown in the following tables. t able 58: t imer 0 pin mapping deviomap.0 bit value t0in mapping t0ex mapping t0out mapping 0 (reset) p3.4 p2.6 p4.5 1 - pin 41 - t able 59: t imer 1 pin mapping deviomap.1 bit value t1in mapping t1ex mapping t1out mapping 0 (reset) p3.5 p2.5 p4.0 1 - pin 40 p1.4
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 33 of 99 6.4 timer 0, timer 1 functional diagram the following diagram represents the main features of timers 0 and 1 f igure 9: t imer 0, timer 1 f unctional d iagram syscl k txin pin trx txgate intx pin 07 tlx clk 8 15 thx pulse touten txmode8 toggle txout pin 0 1 1 0 txovf interrupt txtogout 07 txrlcap 07 rcapxh txclksrc txcounten txclkcfg div ratio: sys clk / 1 downto sys clk / 16384 0 1 t (x-1) out if x = 1 or 2 capture reload txex pin txexen 0 1 rcapxl reloa d capture txdownen down / up down / up 0 1
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 34 of 99 6.5 timer 0, timer1 examples programs 6.5.1 timer 0 1ms delay function ;******************************************************** ;* delay1msto : 1ms delay using timer0 ;*; *calibrated for 40mhz ;********************************************************** delay1mst0: mov cptr,a ;get number of cycles mov a,periphen1 ;load periphen1 reg orl a,#00000001b ;enable timer 0 mov periphen1,a delay1mslp: mov th0,#063h ;t0 reload value for 1ms at 40mhz mov tl0,#0c0h ;mov th0,#0a9h ;t0 reload value for 1ms at 22.11mhz ;mov tl0,#058h mov t0t1clkcfg,#00h ;no prescaler for t0 clock mov t0con,#00000100b ;start t0, count up dwaitovt0: mov a,t0con ;read t0 control, wait for ;overflow anl a,#080h ;isolate timer overflow flag jz dwaitovt0 ;loop as long as t0 don?t overflow mov t0con,#00h ;stop timer 0 djnz cptr,delay1mslp ;out loop mov a,periphen1 ;load periphen1 reg anl a,#11111110b ;disableble timer 0 mov periphen1,a ret 6.5.2 timer 0, timer 1 and timer 2 output toggle example ;******************************************************************************* ;- timer 0, timer 1 and tmer 2, output toggle example * ;******************************************************************************* include <VRS51L2070.inc> ;-- enable timer 0, timer 1 and timer 2 init: mov periphen1,#00000111b ;bit7 - spics en ;bit6 - spien ;bit5 - i2cen ;bit4 - u1en ;bit3 - u0en ;bit2 - t2en ;bit1 - t1en ;bit0 - t0en mov periphen2,#00001000b ;bit7 - pwc1en ;bit6 - pwc0en ;bit5 - auen ;bit4 - xram2code ;bit3 - ioporten ;bit2 - wdten ;bit1 - pwmsfren ;bit0 - fpien ;-- set the system clock prescaler to max speed mov devclkcfg1,#60h ;set device prescaler speed ;** configure and start timer 0, timer 1 & timer 2 mov t0t1cfg,#00001010b ;connect timer0 output t0 p4.5 and ;timer1 output t0 p4.0, timer source ;from sys clk mov t2clkcfg,#00010110b ;t2 ssource = sys clk, t2out ;enabled on p1.2, prescaler = sys ;clk/64 mov t0con,#14h ;start timer0, toggle output mov t1con,#14h ;start timer1, toggle output mov t2con,#14h ;start timer2, toggle output loop: ajmp loop ;infinite loop 6.5.3 timer 0, timer 1 and timer 2 output toggle and timer chaining example ;******************************************************************************************************** ;- timer 0, timer 1 and tmer 2, output toggle + timer chaining example * ;******************************************************************************************************** include <VRS51L2070.inc> init: mov periphen1,#00000111b ;bit7 - spics en ;bit6 - spien ;bit5 - i2cen ;bit4 - u1en ;bit3 - u0en ;bit2 - t2en ;bit1 - t1en ;bit0 - t0en mov periphen2,#00001000b ;bit7 - pwc1en ;bit6 - pwc0en ;bit5 - auen ;bit4 - xram2code ;bit3 - ioporten ;bit2 - wdten ;bit1 - pwmsfren ;bit0 - fpien ;-- set the system clock prescaler to max speed mov devclkcfg1,#60h ;set device prescaler speed ;** configure and start timer 0, timer 1 & timer 2 mov t0con,#14h ;start timer0, toggle output mov t1con,#14h ;start timer1, timer1 toggle ;output mov t2con,#14h ;start timer2, timer2 toggle ;output mov t0t1cfg,#00001000b ;connect timer1 output t0 p4.0 mov t2clkcfg,#00110000b ;timer 2 uses timer1 output as ;clock source, t2 out on p1.2, ;clock prescaler = 1 loop: ajmp loop ;infinite loop
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 35 of 99 6.6 timer 2 the architecture of timer 2 is very similar to that of timers 0 and 1, the main difference being that timer 2 cannot operate as two 8-bit timers. 6.6.1 timer 2 configuration registers the t2con register controls: o timer operation mode (timer or counter) o timer 2 advanced gating features o timer 2 overflow flag o timer 2 counting direction (up/down) o timer 2 reload and capture o timer 2 output mode (pulse/toggle) the t2con register has the same structure as the t0con and t1con registers. t able 60:t imer 2 c onfiguration register - t2con sfr 9c h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 t2ovf timer 2 overflow flag set to 1 when timer overflows from ffffh to 0000h. must be cleared by software. writing 1 into this bit will trigger a timer interrupt, if enabled 6 t2exf timer 2 external flag gating flag set to 1 when timer reload of capture is caused by an high to low transition on the t2ex pin, if t2exen is set to 1 5 t2downen timer 2 count down enable 0 = timer 2 count up 1 = timer 2 counts down 4 t2togout timer 2 output toggle enable 0 = timer 2 output outputs a pulse when it overflows from ffffh to 0000h 1 = timer 2 output toggles when it overflows from ffffh to 0000h 3 t2exten timer 2 external gating enable 0 = t2ex pin is not active 1 = enable timer 1 capture or reload upon a high to low transition on the t2ex pin 2 tr2 timer2 run 0 = timer 2 is stopped 1 = timer 2 is running 1 t2counten timer 2 counter enable 0 = timer 2 acts as a timer 1 = timer 2 acts as a counter that is incremented (decremented) by a high to low transition on t2in pin 0 t2rlcap timer 2 capture enable 0 = auto reload value is loaded in timer 2 if a high to low transition occurs on t2ex, if t2exten is set to 1 1 = timer 2 current value is captured when a high to low transition occurs on the t2ex pin, if t2exten is set to 1 the t2ovf bit of the t2con register indicates whether the timer count has rolled over from ffffh to 0000h. if the corresponding timer interrupt has been activated, the t2ovf will ra ise the timer 2 interrupt.. the t2exf flags are set to 1 when a high to low transition occurs on the t2ex pin, provided that the t2exe pin is set to 1. as is the case for timers 0 and 1, timer 2 can be configured to count up or down. by default, timer 2 counts up. however setting the t2downen bit to 1 will configure timer 2 to count down. when the timer counts downwards, the overflow flag will be set when the timer counts from 0000h to ffffh. the t2counten bit- enables the configuration of timer 2 as a external event counter. by default, timer 2 derives its source from the system clock or a prescaled system clock. setting the t2counten bit to 1 will configure timer 2 to derive its source from the t2in input pin. a high to low transition on the t2in pin will initiate a timer count one step up or down, depending on the value of the corresponding t2downen bit. the t2rlcap bit controls the function of the timer capture/reload register when a high to low transition occurs on the t2ex timer trigger input pin. o t2rlcap = 0 : auto reload value is loaded in timer 2 o t2rlcap = 1 : timer 2 current value will be captured in the rcap2l and rcap2h registers the functions associated with the t2rlcap bit are only activated when the t2exten bit is set to 1. t able 61:t imer 2 l ow - tl2 sfr 8e h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 tl2[7:0] t able 62:t imer 2 h igh ? th2 sfr 8f h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 th2[7:0]
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 36 of 99 6.6.2 timer 2 reload and capture registers t able 63:t imer 2 r eload and c apture l ow ? rcap2l sfr 96 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 rcap2l[7:0] t able 64:t imer 2 r eload and c apture h igh ? rcap2h sfr 97 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 rcap2h[7:0] 6.6.3 the timer 2 clock configuration register the t2clkcfg register is used to configure the clock source for timer 2. the source can be either a prescaled value of the system clock or the output of timer 1. the timer 2 clock source is also controlled by the t2clksrc bit. when this bit is set to 1, timer 2 derives its source from the timer 1 overflow. if t2clksrc is set to 0, timer 2 will derive its source from a prescaled value of the system clock. the division factor applied to the system clock is defined by t2clkcfg[3:0] t able 65:t imer 2 c lock c onfiguration r egister - t2clkcfg sfr 9d h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 - 6 - 5 t2clksrc timer 2 clock source 0 = timer 2 take its clock from system clock 1 = timer 2 takes its clock from timer 1 output 4 t2outen timer 2 output enable 0 = timer 2 output is deactivated 1 = timer 2 output is connected to a pin 3:0 t2clkcfg[3:0] timer 2 clock prescaler configuration see table below the following table outlines the timer 2 prescaler values according to the value of the t2clkcfg[3:0] bits. t able 66:t imer 2 c lock division ratio t2clkcfg (4 bit binary) timer clock div. ratio t2clkcfg timer clock div. ratio 0000 1 1000 256 0001 2 1001 512 0010 4 1010 1024 0011 8 1011 2048 0100 16 1100 4096 0101 32 1101 8192 0110 64 1110 16384 0111 128 1111 16384 6.6.4 timer 2 output as is the case for timers 0 and 1, timer 2?s output can be routed to an external pin. this feature is activated by setting the t2outen bit of the t2clkcfg register to 1. by default, the timer 2 output, when enabled, will generate a pulse upon timer 2 overflow. the duration of the pulse is (1/ sys clk). setting the t2togout bit of the t2con register to 1 will configure timer 2?s output to toggle upon a timer 2 overflow instead of outputting a pulse. f igure 10: t imer 2 o utput modes timer2 overflow t2outen = 1 t2togout = 1 t2outen = 1 t2togout = 0 6.7 timer 2 alternate mapping bit 2 of the deviomap register (sfr e1h) controls the mapping of the timer 2 interface as shown in the following table: t able 67: t imer 2 pin mapping deviomap.2 bit value t2in mapping t2ex mapping t2out mapping 0 (reset) p1.0 p1.1 p1.2 1 p6.1 p6.0 p4.4 alternate mapping allows timer 2?s output to be mapped into p4.4 instead of p1.2. this can be useful for applications where both uart0 and uart1 are required.
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 37 of 99 6.8 timer 2 functional diagram the following diagram describes the main features of timer 2. f igure 11: t imer 2 f unctional d iagram sysclk t2in pin tr2 t2gate intx pin 07 tlx clk 8 15 thx pulse t2outen toggle txout pin 0 1 t2ovf interrupt t2togout 07 t2rlcap 07 rcap2h t2clksrc t2counten t2clkcfg div ratio: sys clk / 1 downto sys clk / 16384 0 1 t1out capture reload t2ex pin t2exen 0 1 rcap2l reload capture t2downen down / up down / up 0 1
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 38 of 99 6.9 timer chaining capability the three VRS51L2070 timers can be chained together to form a 24-, 32- or 48-bit timer that can be used for very long delay ti ming. longer delays can be achieved by using the system clock prescalers. the following provides an example of time delays that can be achieved by timer chaining: t able 68: t ime delays vs . t imer size for 40mh z s ystem c lock timer size time out period 16 bit 1.638 milliseconds 24 bit 419 milliseconds 32 bit 107 sec-seconds 48 bit 7.037x10e6 seconds (1954.6 hours) the following diagram provides a schematic representation of timer chaining. f igure 12: t imer chaining sys clk t0clkcfg div ratio: sys clk / 1 down to sysclk / 16384 t2clkcfg div ratio: sys clk / 1 down to sysclk / 16384 0 1 timer 2 timer 1 t1clkcfg div ratio: sys clk / 1 down to sysclk / 16384 0 1 timer 0 out out out t1clksr c t2clksr c note that timer chaining does not affect other timer features such as: o timer capture o timer auto-reload o timer output it is also possible to couple the timer chaining capability with the pulse width counter (see next section), to count long duration events. 7 pulse width counters (pwc) the VRS51L2070 provides two independent pulse width counter modules associated with timers 0 and 1. the pulse width counter modules provide advanced timer control, allowing the user to define which event will trigger the timer to st art and stop. contrary to standard timer capture module units, the pwc unit can be used to measure the duration of an event. the following two diagrams provide a schematic view of the pwc modules? structure and functionality. f igure 13: pwc0 m odule s tructure pwc0rst timer 0 timer 0 div ratio: sys clk / 1 downto sys clk / 16384 sys clk 015 00 01 10 11 edge detec t edge detec t 0 1 00 01 10 11 edge detec t edge detec t 0 1 pwc0stsrc pwc0endsrc p3.2-int0 pin p3.0-rxd0 pin p2.4-pwm4 pin p3.4-t0in-scl pin rst rst rst rst rst pwc0stpol pwc0endpol pwc0if pwc0rst (status) f igure 14: pwc1 m odule s tructure pwc1rst timer 1 timer 1 div ratio: sys clk / 1 downto sys clk / 16384 sys clk 015 00 01 10 11 edge detec t edge detec t 0 1 00 01 10 11 edge detec t edge detec t 0 1 pwc1stsrc pwc1endsrc p3.3-int1 pin p1.2-rxd1 pin rxd1 pin p1.6-sck pin rst rst rst rst rst pwc1stpol pwc1endpol pwc1if pwc1rst (status) the pwc modules interact with timers 0 and 1. combining the pwc module configuration with the timer configuration provi des added flexibility to the operating modes.
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 39 of 99 two sfr registers (pwc0cfg and pwc1cfg located at addresses 9eh and 9fh, respectively) are dedicated to pwc configuration. t able 69:p ulse w idth c ounter 0 c onfig . register - pwc0cfg sfr 9e h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 pwc0if pulse width counter module 0 interrupt flag 0 = no pwc0 interrupt occurred 1 = pwc0 interrupt occurred read: pulse width counter operation status 0 = pwc0 is waiting for start condition 1= pwc0 is currently counting 6 pwc0rst write: pulse width counter reset 0 = no action 1 = reset pwc0 operation and pwc0if pwc0 will wait for a start condition 5 pwc0endpol pwc0 end event polarity 0 = pwc0 end event is a rising edge 1 = pwc0 end event is a falling edge 4 pwc0stpol pwc0 start event polarity 0 = pwc0 start event is a rising edge 1 = pwc0 start event is a falling edge 3:2 pwc0endsrc [1:0] pwc0 end source 00 = p3.2 01 = p3.0 10 = p2.4 11 = p3.4 1:0 pwc0stsrc [1:0] pwc0 start source 00 = p3.2 01 = p3.0 10 = p2.4 11 = p3.4 t able 70:p ulse w idth c ounter 1 c onfig . register - pwc1cfg sfr 9f h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 pwc1if pulse width counter module 0 interrupt flag 0 = no pwc1 interrupt occurred 1 = pwc1 interrupt occurred read: pulse width counter operation status 0 = pwc1 is waiting for start condition 1= pwc1 is currently counting 6 pwc1rst write: pulse width counter reset 0 = no action 1 = reset pwc1 operation and pwc0if pwc0 will wait for a start condition 5 pwc1endpol pwc1 end event polarity 0 = pwc1 end event is a rising edge 1 = pwc1 end event is a falling edge 4 pwc1stpol pwc1 start event polarity 0 = pwc1 start event is a rising edge 1 = pwc1 start event is a falling edge 3:2 pwc1endsrc [1:0] pwc1 end source 00 = p3.3 01 = p1.2 10 = rxd1 11 = p1.6 1:0 pwc1stsrc [1:0] pwc1 start source 00 = p3.3 01 = p1.2 10 = rxd1 11 = p1.6 the configuration of the pwc module involves the following steps: o activate pwc module o activate timer and configure it in gating mode o configure pwc start and stop source o configure pwc start and stop event o initialize timer to 0x0002 o activate pwc interrupt if required 7.1.1 pwc module and timer initialization the pwc0/1 modules operate in conjunction with timers 0/1. the timer must be activated and configured in gating mode immediately after the pwc modules have been enabled. to obtain a precise measurement of the event duration, the timer registers [thx,tlx] must be initialized to 00, 02h. once a stop event occurs, t he event duration in terms of system cycles is stored in the timer registers. once the timer has been read, the so ftware must clear it for the next event. // pwc0 timer initialization ptr = (char idata *) &result_dump_start_address_pwc0; periphen2 |= 0x40; //enable pwc0 (enabled first to gate timer //before timer enable !!!) periphen1 |= 0x01; //enable timer 0 t0t1cfg = 0x02; //set timer 0 in gate mode tl0 = 0x02; /initialize timer th0 = 0x00; pwc0cfg |= 0x15; //configure pwc0 module to start on a falling edge and //end on a rising edge on pin p3.0 for both events the timer start source can differ from the timer stop source and the start event can differ from the end event. the pwc start and end sources are defined by the pwcxstsrc bits of the pwcxcfg register as shown in the following tables: t able 71:p ulse w idth c ounter 0 s tart / s top souce co nfiguration pwc0stsrc pwc0 start source pwc0endsrc pwc0 end source 00 p3.2 ? int0 00 p3.2 ? int0 01 p3.0 ? rxd0 default 01 p3.0 ? rxd0 default 10 p2.4 ? rxd0 alternate 10 p2.4 ? rxd0 alternate 11 p3.4 ? t0in 11 p3.4 ? t0in t able 72:p ulse w idth c ounter 1 s tart / s top souce co nfiguration pwc1stsrc pwc1 start source pwc1endsrc pwc1 end source 00 p3.3 ? int1 00 p3.3 ? int1 01 p1.2 ? rxd1 default 01 p1.2 ? rxd1 default 10 rxd1 alternate 10 rxd1 alternate 11 p1.6 11 p1.6
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 40 of 99 start and stop events must be triggered by either a rising edge or a falling edge of the selected start and stop source. the pwc start source polarity is defined by the pwcxstpol and the stop source polarity is defined by the pwxcendpol. when these bits are cleared, the pwc module will be triggered by a rising edge (low to high). setting these bits to 1 configures the pwc to be triggered by a falling edge (high to low). 7.1.2 pwc module reset and interrupt flags the pwcxrst bit, when set to 1 will force a reset of the pwc module and clear the pwcxif flag if it is set. the pwc module will then wait for the start condition. the pwcxrst flag provides the current state of the pwc module as follows: t able 73: d efinition of pwc x rst bit when read pwcxrst reads as then? 0 pwc module is waiting for a start condition 1 pwc module is currently counting the pwcxif bit will be set to 1 when a stop condition is encountered by the pw c module. the pwcxif must be cleared by the program. one interrupt vector (int 11) is allocated for the two pwc modules and its vector address is 005bh. note: o the pwcxif flag remains active even if the corresponding pwc interrupt is disabled. o the pwcxif flags are not automatically cleared when exiting the interrupt service routine. they must be cleared manually by the software. 7.2 pwc example program the following example program demonstrates how to configure and use the pwc1 module in pooling mode. //-----------------------------------------------------------------------------------------------------------------// // v2k_pwc1p1in_t2out_sdcc.c // //---------------------------------------------------// // // description: for this demonstration program timer 2 is configured to // continuously run in output toggle mode on its alternate output (p1.2) and // is used to generate the stimuli required for the pwc1 module input. // the port 0 is used to monitor the activity of the pwc1 module. // // target: vrs51l2xxx/vrs51l3xxx // // #include <VRS51L2070_sdcc.h> void main (void) { //enable timer 0 and timer 2 //--initialize pwc1 periphen2 |= 0x088; //enable the pwc1 module & ioport periphen1 |= 0x02; //enable timer 1 p0pincfg = 0x00; //p0 = output t0t1cfg |= 0x40; //set timer 1 in gating mode th1 = 0x00; //initialize timer 1 to 0x02 tl1 = 0x02; // t1con |= 0x04; //run timer 1 //configure timer 2 as a timer with output toggle periphen1 |= 0x04; // timer 2 th2 = 0xa0; //config timer 2 initial value tl2 = 0x00; rcap2h = 0xa0; //config timer 2 reload value rcap2l = 0x00; //configure timer clock source & output enable t2clkcfg = 0x10; //t2 clk source = system clock //t2 output enable //prescaler = fosc / 1 //configure timer 2 alternate output deviomap |= 0x04; //config t2 output toggle and start timer t2con = 0x14; //timer 2 output toggle //timer 2 run //timer mode from sys clk //configure pwc1 to start t1 on a rising edge & stop t1 on a falling edge //(will measure t2 period) pwc1cfg = 0x65; //bit 6 = 1: reset pwc (bit 6 = 1) //bit 5 = 1: start on rising edge //bit 4 = 0 stop on rising edge //bit 3:2 = 01 pwc1 start / stop input = p1.2- t2out* //infinite loop of pwc1 module monitoring by pooling //the p0 is used to monitor the activity of the pwc1 module //when the pwc1 start condition is met, the program set p0 to 0x00 //and return it to 0xff when the stop condition occurs p0 = 0xff; //set p0 to 0xff (pwc not running) do{ //pwc1cfg |= 0x40; //force the pwc1 module to wait for a start condition while(!(pwc1cfg&0x40)); //wait pwc to start p0 = 0x00; //clear p0 while(!(pwc1cfg&0x80)); //wait pwc stop condition to occurs ie interrupt found p0 = 0xff; //return p0 to ff to indicate pwc stopped pwc1cfg &= 0x7f; tl1 = 0x02; //initialize timer 1 to 0x02 th1 = 0x00; }while(1); }// end of main
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 41 of 99 8 uart serial ports the serial ports on the VRS51L2070 operate in full duplex mode. however, the communication speed will be the same for transmission and reception. communication speed is derived from an internal 16- bit baud rate generator dedicated to each of the uarts. 8.1 uart0 rx / tx data buffer the serial port features double buffering on the receiving side. the sfr register, uart0buf, provides access to the transmit and receive registers of the serial port. when a read operation is performed on the uart0buf register, it will access the receive register double buffer. when a write operation is performed on the uart0buf, the transmit register will be loaded with the value to be transmitted. t able 74:uart0 data rx / tx r egister uart0buf sfr a3 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 uart0buf[7:0] read: uart0 receive buffer write: uart0 transmit buffer 8.2 uart0 configuration registers the configuration of the ua rt0 is controlled by the uart0cfg, the uart0brh and uart0blh registers and the uart 0ext registers. t able 75:uart0 configuration register - uart0cfg sfr a2 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 1 1 1 0 0 0 0 0 bit mnemonic description 7:4 bradj[3:0] uart0 baud rate fine adjustment * see formula below 3 brclksrc baud rate clock source 0 = baud rate generator uses oscillator 1 = baud rate generator uses external clock source 2 b9rxtx read: last received 9 th bit write: 9 th bit to transmit 1 b9en 9 th bit mode enable 0 = data transfer are in 8-bit format 1 = data transfer are in 9-bit format 0 stop2en enable two stop bit mode 0 = one stop bit 1 = two stop bit t able 76:uart0 b aud r ate r egister l ow ? uart0brl sfr a4 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 uart0brl[7:0] uart0 lsb of baud rate generator t able 77:uart0 b aud r ate r egister h igh ? uart0brh sfr a5 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 uart0brh[7:0] uart0 msb of baud rate generator t able 78:uart0 e xtensions c onfiguration - uart0ext sfr a6 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 1 0 0 0 0 0 bit mnemonic description 7 u0timerf uart0 timer flag 6 u0timeren uart0 timer enable 5 u0rxstate uart0 rx line state 4 multiproc when set, rx_available only raise if the ninth received bit is '1' 3 j1708pri[3:0] when a transmit is requested, it starts after the ? priority ? bit to ?1? has been probed on the rx line a standard uart has ?0000? priority 8.3 uart0 interrupt configuration register the activation of the uart0 interrupt is a two-stage process that involves enabling the interrupts at the uart0 module level and then activating the uart0 interrupt at the system level through the inten1 register. the upper nibble of the uart0int register contains the uart0 interrupt activation bits and the lower nibble contains the uart0 interrupt flags in the same order. two interrupt vectors are as sociated with uart0. the first interrupt vector is at address 002bh and handles all uart0 interrupt conditions, except for the uart0 data collision interrupt (vector address 0053h), which is shared with the uart1 data collision and the i2c master lost arbitration interrupts. the interrupt flags allow the interrupt service routine to define which condition triggered the interrupt, and to react accordingly. note that the interrupt flags do not require the interrupt to be enabled in order to be operational. they can be moni tored by the software at any time.
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 42 of 99 t able 79: uart0 i nterrupt r egister - uart0int sfr a1 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r, w r/w r/w r 0 0 0 0 0 0 0 1 bit mnemonic description 7 colen uart0 collision interrupt enable 0 = collision interrupt is deactivated 1 = collision interrupt is enabled 6 rxoven uart0 rx overrun interrupt enable 0 = rx overrun interrupt is deactivated 1 = rx overrun interrupt is enabled 5 rxavailen uart0 rx available interrupt enable 0 = rx available interrupt is deactivated 1 = rx available interrupt is enabled 4 txemptyen uart0 tx empty interrupt enable 0 = tx empty interrupt is deactivated 1 = tx empty interrupt is enabled (read) collision interrupt flag when this flag is set by the uart0 module, it indicates that a collision occurred 3 colenf (write) 0 = collision detection is disabled and the collision colenf is reset 1 = a bus collision stops the transmission and raises the colenf flag 2 rxovf uart0 rx overrun flag when set to 1 by the uart0 interface, it indicates that a data collision occurred in the uart0buf register 1 rxavenf uart0 rx available flag when set to 1 by the uart0 interface, it indicates that data has been received in the uart0buf register writing 1 into this bit position will activate reception on uart0 0 txemptyf uart0 tx empty flag when set to 1, it indicates that the transmit portion of the uart0buf is ready to receive another byte 8.4 uart1 rx/tx data buffer the sfr register (uart1buf) provides access to the transmit and receive registers of the serial port. when a read operation is performed on the uart1buf register, it will access the re ceive register. when a write operation is perform ed on the uart1sbuf, the transmit register will be loaded with the value to be transmitted. t able 80:uart1 data rx / tx r egister uart1buf sfr b3 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 uart1buf[7:0] read: uart1 receive buffer write: uart1 transmit buffer 8.5 uart1 configuration registers the configuration of the ua rt1 is controlled by the uart1cfg, uart1brh and uart1blh registers and the uart1ext registers. t able 81:uart1 configuration register - uart1cfg sfr b2 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 1 1 1 0 0 0 0 0 bit mnemonic description 7:4 bradj[3:0] uart1 baud rate fine adjustment * see formula below 3 brclksrc baud rate clock source 0 = baud rate generator uses oscillator 1 = baud rate generator uses external clock source 2 b9rxtx read: last received 9 th bit write: 9 th bit to transmit 1 b9en 9 th bit mode enable 0 = data transfer are in 8-bit format 1 = data transfer are in 9-bit format 0 stop2en enable two stop bit mode 0 = one stop bit 1 = two stop bit t able 82:uart1 b aud r ate r egister l ow ? uart1brl sfr b4 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 uart1brl[7:0] uart1 lsb of baud rate generator t able 83:uart1 b aud r ate r egister h igh ? uart1brh sfr b5 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 uart1brh[7:0] uart1 msb of baud rate generator
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 43 of 99 t able 84:uart1 e xtensions c onfiguration - uart1ext sfr b6 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 1 0 0 0 0 0 bit mnemonic description 7 u1timerf uart1 timer flag 6 u1timeren uart1 timer enable 5 u1rxstate uart1 rx line state 4 multiproc when set, rx_available, only raise if the ninth received bit is '1' 3:0 j1708pri[3:0] when a transmit is requested, it starts after the ? priority ? bit to ?1? has been probed on the rx line a standard uart has ?0000? priority 8.6 uart1 interrupt configuration register the activation of uart1?s interrupt is a two stage process that involves enabling the interrupts at the uart1 module level and then activating the uart1 interrupt at the system level through the inten1 register. t able 85: uart1 i nterrupt r egister - uart1int sfr b1 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r, w r/w r/w r 0 0 0 0 0 0 0 1 bit mnemonic description 7 colen uart1 collision interrupt enable 0 = collision interrupt is deactivated 1 = collision interrupt is enabled 6 rxoven uart1 rx overrun interrupt enable 0 = rx overrun interrupt is deactivated 1 = rx overrun interrupt is enabled 5 rxavailen uart1 rx available interrupt enable 0 = rx available interrupt is deactivated 1 = rx available interrupt is enabled 4 txemptyen uart1 tx empty interrupt enable 0 = tx empty interrupt is deactivated 1 = tx empty interrupt is enabled (read) collision interrupt flag when this flag is set by the uart1 module, it indicates that a collision has occurred 3 colenf (write) 0 = collision detection is disabled and the collision colenf is reset 1 = a bus collision stops the transmission and raises the colenf flag 2 rxovf uart1 rx overrun flag when set to 1 by the uart1 interface, it indicates that a data collision has occurred in the uart0buf register 1 rxavenf uart1 rx available flag when set to 1 by the uart1 interface, it indicates that data has been received in the uart1buf register writing 1 into this bit position will activate reception on uart1 0 txemptyf uart1 tx empty flag when set to 1, it indicates that the transmit portion of the uart1buf is ready to receive another byte 8.7 uart0, uart1 baud rate formula the uart0 baud rate is programmed using the following formula: baud rate = fclk 32x (uartxbr[15:0] + bradj[3:0]/16 + 1) the bradj[3:0] bits are used for fine adjustment of the baud rate. the following steps demonstrate using the uartxbr[15:0] and bradj[3:0] registers to set the appropriate baud rate. step 1: defining the optimal uartxbr[15:0] value use the following formula to set the uartxbr[15:0] register to the integer component of uartxbrideal: uartxbr ideal = fclk - 1 32x (baud rate ) note that the baud rate will likely contain a fractional component. valid uartxbr[15:0] values range from 0x0000 to 0xffff. step 2: defining the optimal bradj[3:0] value use the following formula to set the bradj[3:0]: bradj[3:0] = int[ (uartxbrideal ? uartxbr[15:0]) * 16] the bradj[3:0] register can only contain an integer value between 0x00 and 0x0f. step 3: calculating the error the actual baud rate vs. the ideal baud rate can be calculated using the following formula: error % = 100x [ (fclk /32*(uartxbr[15:0 +bradj[3:0]/16 +1))-baud rate] baud rate in order to achieve reliable communication, the error should be below 2 percent. the following table provides configuration examples for typical baud rates when the internal 40mhz oscillator is used:
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 44 of 99 t able 86: uarts b aud r ate configurat ion examples ( sys clk =40m hz ) com speed uartxbr [15:0] bradj [3:0] actual baud rate error (%) 230400bps 0004h 07h -0.22 115200bps 0009h 0eh -0.22 57600bps 0014h 0bh 0.06 38400bps 001fh 09h -0.03 31250bps 0027h 00h 0 28800bps 002ah 06h 0.06 19200bps 0040h 02h -0.03 9600bps 0081h 03h 0.01 4800bps 0103h 07h -0.01 2400bps 0207h 0dh 0 1200bps 0410h 0bh 0 300bps 1045h 0bh 0 8.8 uart0, alternate mapping upon reset, uart0?s rxd0 and txd0 signals are mapped into pins p3.0 and p3.1, respectively. it is possible to re-map the rxd0 and txd0 signals into pins p2.4 and p2.3. bit 3 of the deviomap register (sfr e1h) controls the mapping of the uart0 interface, as shown in the following table: t able 87: uart0 rxd0 / txd0 pin mapping deviomap.3 bit value rxd0 mapping txd0 mapping 0 (reset) p3.0 p3.1 1 p2.4 p2.3 when alternate mapping for uart0 is used, the uart0 will have priority over the pwm3 and pwm4 outputs. 8.9 uart1, alternate mapping upon reset, uart1?s rxd1 and txd1 signal are mapped into pins p1.2 and p1.3, respectively. it is possible to map uart1?s rxd1 and txd1 signals into pins 41 and 40 of the VRS51L2070. bit 4 of the deviomap register (sfr e1h) controls the mapping of the uart1 interface as shown in the following table: t able 88: uart1 rxd1 / txd1 pin mapping deviomap.3 bit value rxd1 mapping txd0 mapping 0 (reset) p1.2 p1.3 1 pin 41 pin 40
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 45 of 99 8.10 uart0 and uart1 example programs configuration of uart0 is essentially the same as uart1 8.10.1 uart0 string transmit //-------------------------------------------------------------------------------------------------// // vrs2k-uart0_string_out_sdcc.c // //---------------------------------------------------// // // this program initialize the uart0 at 115200 (with sosc = 39.2mhz) // and then send a string on uart0 txd0 //----------------------------------------------------------------------------------------------------// #include <VRS51L2070_sdcc.h> // --- function prototypes void txmit0( unsigned char charact); void uart0config(void); //------------------------------------// // main function // //------------------------------------// char msg[] = "VRS51L2070 by ramtron inc. \0"; void main (void) { int cptr = 0x00; //general purpose counter char value = 0x00; //general purpose variable periphen1 = 0x08; //enable uart0 (sfr = f5h) periphen2 = 0x08; //enable i/o ports (sfr = f5h) p2pincfg = 0xfe; //configure port 2.0 as output //-- system clock prescaler devclkcfg1 = 0x60; //set device prescaler speed uart0config(); //configure uart0 //-- send message 1 on uart0 do{ cptr = 0x00; // init cptr to pint to message beginning do{ txmit0(msg[cptr++]); }while(msg[cptr]!= '\0'); txmit0(13); //send carriage return txmit0(10); //send line feed }while(1); }//end of main //----------------- individual functions --------------------- //--------------------------------------------------------------------------------// // uart0 config with s0rel // // configure the uart0 to operate in rs232 mode at 115200bps // with self oscillator at 39.2mhz // //--------------------------------------------------------------------------------// void uart0config() { //--initialize uart0 at 115200bps @ 39.2mhz uart0cfg = 0x90; //no fine adjustment on baud rate //use internal clock //9 bit not used //only one stop bit uart0ext = 0x00; //not using uart0 extensions uart0brl = 0x09; //reload for 115200 uart0brh = 0x00; // }//end of uart0config() function //--------------------------------------------------------------------------------// // txmit0 // // transmit one byte on the uart0 // //--------------------------------------------------------------------------------// void txmit0( unsigned char charact){ char patof; s0buf = charact; //send character do{ //wait for tx empty flag to be set patof = uart0int; patof = patof & 0x01; }while (patof == 0x00); uart0int &= 0xfe; }//end of txmit0() function 8.10.2 uart echo and external interrupt configuration //----------------------------------------------------------------------------------------------------------// // vrs2k-uart0_echo_int0_int1_interrupt_sdcc.c // //----------------------------------------------------------------------------------------------------------// // // this program initialize the uart0 at 115200 (with sosc = 40mhz) // it then transmit "instruction message" on txd0 // and enter in infinite loop waiting for an interrupt // as soon as a character is received it is transmitted back on txd0 // //----------------------------------------------------------------------------------------------------------// #include <VRS51L2070_sdcc.h> //----global variables ------// int cptr = 0x00; //general purpose counter // --- function prototypes void txmit0( unsigned char charact); void uart0config(void); //--definton of messages to transmit on uart0 char msg[] = "uart0 echo + int test: waiting for char on rxd0 or ext int0 or ext int1...\0"; char msgint0[] = "ext int0 received"; //-----------------------------------// //----- interrupt int0 ------// //----------------------------------// void int0interrupt(void) interrupt 0 { //-- send "ext int0 received" on uart0 cptr = 0x00; //init cptr to pint to message beginning inten1 = 0x00; //disable uart0 interrupt do{ b = msgint0[cptr++]; txmit0(b); }while(msgint0[cptr]!= '\0'); txmit0(13); //send carriage return txmit0(10); //send line feed inten1 = 0x21; //enable uart0 interrupt + int0 }//end of int0 interrupt //---------------------------------------// //--- uart0 interrupt --------// //--------------------------------------// void uart0interrupt(void) interrupt 5 { char genvar; //check if interrupt was caused by rx avail genvar = uart0int; genvar &= 0x02; // if(genvar != 0x00) { genvar = s0buf; txmit0(genvar); //send back the received character }
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 46 of 99 //check if interrupt was caused by rx overrun genvar = uart0int; genvar &= 0x04; // if(genvar != 0x00) { genvar = s0buf; //read s0buf to clear rx ov condition... //his is mandatory because otherwise the rx ov condition //stay active //interrupt activated // uart0int = 0x32; //enable rx av int + tx empty int + enable reception txmit0(' '); //send " ov!" on serial port txmit0('o'); // txmit0('v'); // txmit0('!'); // } }//end of uart0 interrupt //-----------------------------------------// // main function // //----------------------------------------// void main (void){ char value = 0x00; //general purpose variable periphen1 = 0x08; //enable uart0 periphen2 = 0x08; //enable io ports p2pincfg = 0xfe; //configure port 2.0 as output //-- system clock prescaler devclkcfg1 = 0x60; //set device prescaler speed uart0config(); //configure uart0 //-- send "hello" on uart0 cptr = 0x00; //init cptr to pint to message beginning do{ txmit0(msg[cptr++]); }while(msg[cptr]!= '\0'); txmit0(13); //send carriage return txmit0(10); //send line feed //--wait for character on uart0 interrupt // once a character is received, grab it and send it back uart0int = 0x62; //test: for rxov int test enable rx ov int + enable //reception intsrc1 = 0x01; //int0 vector source = int0 pin intpinsens1 = 0x01; //set int0 sensitive on edge(1) or level(0) intpininv1 = 0x00; //set int0 pin sensitivity on low level/inversion inten1 = 0x21; //enable int0 (bit0) and uart0 (bit5) interrupt intconfig = 0x01; //enable global interrupt while(1); }//end of main //----------------- individual functions --------------------- //-----------------------------------------------------------------------------------------------------// // uart0 config with s0rel // // configure the uart0 to operate in rs232 mode at 115200bps // with self oscillator at 39.2mhz // //------------------------------------------------------------------------------------------------------// void uart0config() { //--initialize uart0 at 115200bps @ 39.2mhz uart0cfg = 0x90; //no fine adjustment on baud rate //use internal clock //9th bit not used //only one stop bit uart0int = 0x62; //enable rx av + rxo v int + enable reception uart0ext = 0x00; //not using uart0 extensions uart0brl = 0x09; //reload for 115200 ??? (was 0x0a) uart0brh = 0x00; // }//end of uart0ws0relcfg() function //--------------------------------------------------------------------------------// // txmit0 // // transmit one byte on the uart0 // //--------------------------------------------------------------------------------// void txmit0( unsigned char charact){ char variable; s0buf = charact; //send character do{ //wait for tx empty flag to be set variable = uart0int; variable = variable & 0x01; }while (variable == 0x00); // uart0int &= 0xfe; }//end of txmit0() function
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 47 of 99 9 spi interface the VRS51L2070?s spi interface peripheral is based on the versa mix 8051 spi interface peripheral, but with additional features. key features include: ? supports four standard spi modes (clock phase/polarity) ? operates in master and slave modes ? automatic control of up to four chip select lines ? configurable transaction size (1 to 32 bits) ? transaction size of >32 bits is possible ? double rx and tx data buffers ? configurable msb or lsb first transaction ? generation frame select/load signals f igure 15: spi i nterface o verview processor spi sfrs spi irqs VRS51L2070 spi interface serial data in serial data out serial clock in/out sdi sdo sck cs0 cs1 cs2 cs3 ss chip select output chip select output chip select output slave select input chip select output to slave device #1 to slave device #2 to slave device #3 to slave device #4 from master device before the spi can be accessed it must first be enabled by setting the spien bit of the periphen1 register to 1. 9.1 spi control registers the spictrl register controls the operating modes of the spi interface in master mode. t able 89:spi c ontrol r egister - spictrl sfr c1 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 1 bit mnemonic description 7 spiclk[2:0] spi communication speed (master mode) 000 = sys clk / 2 ( / 8 if spislow = 1) 001 = sys clk / 4 ( / 16 if spislow = 1) 010 = sys clk / 8 ( / 32 if spislow = 1) 011 = sys clk / 16 ( / 64 if spislow = 1) 100 = sys clk / 32 ( / 128 if spislow = 1) 101 = sys clk / 64 ( / 256 if spislow = 1) 110 = sys clk / 128 ( / 512 if spislow = 1) 111 = sys clk / 256 ( / 1024 if spislow = 1) 4 spics[1:0] spi active chip select line (master mode) 00 = cs0 is active 01 = cs1 is active 10 = cs2 is active 11 = cs3 is active 2 spiclkph spi clock phase 0 = sd0 output on rising edge and sdi sampling on falling edge 1= sd0 output on falling edge and sdi sampling on rising edge 1 spiclkpol spi clock polarity 0 = sck stays at 0 when spi is inactive 1 = sck stays at 1 when spi is inactive 0 spimaster spi master mode enable 0 = spi operates in slave mode 1 = spi operate in master mode (default) when the spimaster bit is set to 1, the spi interface operates in master mode. th is is the default operating mode of the VRS51L2070 spi interface after reset. 9.2 setting up clock phase and polarity the clock phase and polarity is controlled by the spiclkph and spiclkpol bits, respectively. the following diagrams show the communication timing associated with the cl ock phase and polarity. spi mode 0: f igure 16: spi m ode 0 cs x sck sdi sdo spi mode 0: spickpol =0,spickph =1 (normal mode shown) msb lsb *arrows indicate the edge where the data acquisition occurs
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 48 of 99 spi mode 1: f igure 17: spi m ode 1 msb lsb cs x sck sdi sdo spi mode 1: spickpol =0,spickph =0 (normal mode shown) *arrows indicate the edge where the data acquisition occurs spi mode 2: f igure 18: spi m ode 2 cs x sdo spi mode 2: spickpol =1,spickph =1 (normal mode shown) sck sdi msb lsb *arrows indicate the edge where the data acquisition occurs spi mode 3: f igure 19: spi m ode 3 cs x sdi sdo spi mode 3: spickpol =1,spickph =0 (normal mode shown) sck msb lsb *arrows indicate the edge where the data acquisition occurs 9.3 defining active chip select line as previously mentioned, only one chip select line is activated when communicating with an external spi slave device. the spics bits of the spictrl register are used to select which cs line will be activated during the transfer . note that with the except ion of the cs0 line, the spicsen bit of the periphen 1 register must be set to 1 in order for the spi be able to control the spi cs lines. 9.4 setting the spi communication speed (master mode) in master mode, the spi interface communication speed is adjustable from ?system clock /2? down to ?system clock / 1024?. slower communication speeds can be useful for interfacing with slower devices or to adjust the communication speed to specific bus conditions. the spiclk sfr register and the spislow bit of the of the spiconfig sfr register control the spi communication speed. the spi communication speed in master mode can be calculated using the following formula: spi speed = sys clk [ 2 (spiclk[2:0] +1) x 4 spislow ] where: o sys clk = processor operating clock o spislow = can be either 0 or 1 o spiclk[2:0] = from 0 to 7 the following tables provide example setting for spi communication speeds with various system clock and spiclk[2:0] and spislow bit settings. t able 90:spi c ommunication s peed example (spislow = 0) spiclk com speed @ 40mhz com speed @ 22.18mhz com speed @ 4mhz 000 20 mhz 11.05 mhz 2 mhz 001 10 mhz 5.53 mhz 1 mhz 010 5 mhz 2.76 mhz 500 khz 011 2.5 mhz 1.38 mhz 250 khz 100 1.25 mhz 691.2 khz 125 khz 101 625 khz 345.6 khz 62.5 khz 110 312.5 khz 172.8 khz 31.3 khz 111 156.3 khz 86.4 khz 15.6 khz t able 91:spi c ommunication s peed example (spislow = 1) spiclk com speed @ 40mhz com speed @ 22.18mhz com speed @ 4mhz 000 5 mhz 2.76 mhz 500 khz 001 2.50 mhz 1.38 mhz 250 khz 010 1.25 mhz 691.2 khz 125 khz 011 625 khz 345.6 khz 62.5 khz 100 312.5 khz 172.8 khz 31.3 khz 101 156.3 khz 86.4 khz 15.6 khz 110 78.1 khz 43.2 khz 7.8 khz 111 39.1 khz 21.6 khz 3.9 khz
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 49 of 99 9.5 spi configuration and status registers the spi configuration and status registers allow the activation and the monitoring of the spi interface interrupts. they also prov ide access to the advanced features of the spi interface such as: o frame select/load generation on cs3 o activating manual control of the chip select lines o bit reversed mode (bitwise endian control) o interrupt activation and monitoring o monitoring the state of the ss pin t able 92:spi c onfiguration register - spiconfig - c2 h 7 6 5 4 3 2 1 0 r/w w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 spimancs spi manual cs mode enable 0 = spi chip select control is fully automatic 1 = spi chip select will be brought low by the spi interface, and will stay low until 0 is written into spimancs bit 6 spiunderc spi clear tx underrun flag (spiunderf) writing a 1 into this bit will clear the spiunder bit of the spistatus register this bit always reads 0 5 fsoncs3 frame select pulse on cs3 0 = cs3 acts in standard ways 1 = the spi interface will send an active low frame select pulse on cs3 frame select has priority on spiload function 4 spiloadcs3 load pulse on cs3 0 = cs3 acts in standard way or as frame select pulse, if fsoncs3 is set to 1 1 = the spi interface sends an active low load pulse on the cs3 pin, if fsoncs3 is cleared 3 spislow spi slow speed mode 0 = spi transaction occurs at normal speed 1 = spi transaction is 4x slower 2 spirxoven spi rx overrun interrupt enable 0 = spi rx overrun interrupt is deactivated 1 = spi rx overrun interrupt is enabled 1 spirxaven spi rx available interrupt enable 0 = spi rx available interrupt is deactivated 1 = spi rx available interrupt is enabled 0 spitxeen spi tx empty interrupt enable 0 = spi tx empty interrupt is deactivated 1 = spi tx empty interrupt is enabled the spistatus register?s role is mainly for monitoring purposes. t able 93:spi s tatus register - spistatus sfr c9 h 7 6 5 4 3 2 1 0 r/w r r r r r r r 0 0 0 1 1 0 0 1 bit mnemonic description 7 spireverse spi reverse mode 0 = spi operates in normal mode (msb first) 1 = spi operates in reverse mode (lsb first) 6 - not used 5 spiunderf spi tx underrun flag 0 = no underrun condition noticed 1 = indicates that the spi transmit buffer has not been fed in time. this condition is likely to occur when the transaction size is > 32 bits this bit is cleared by setting to 1, the spiclrtxf bit of the spictrl bit of the spiconfig register 4 sspinval slave select pin value 0 =ss pin is low 1 = ss pin is high 3 spinocs spi no chip select 0 = at least on chip select line is active 1 = indicates that all the chip select lines are inactive (high) 2 spirxovf spi rx overrun interruptflag 0 = no spi rx overrun condition detected 1 = spi data collision occurred 1 spirxavf spi rx available interrupt flag 0 = spi receive buffer is empty 1 = data is present in the spi rx buffer 0 spitxempf spi tx empty interrupt flag 0 = spi transmit buffer is full 1 = spi transmit buffer is ready to receive new data 9.6 spi transact ion directions the spi interface can perform transactions in the standard spi format (msb first) as well as in the reverse format (lsb first). in applications where data must be transmitted (or received) in lsb first format, the user would normally need to perform bit reversal manually at the processor level and then send the data through the spi interface. the spi interface can automatically handle the bit reversal operations, unloading the processor for other tasks. when the spireverse bit of the spistatus register is set to 0, the spi transact ions will take place in msb first format.
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 50 of 99 the following examples show the timing related to these transaction directions: f igure 20: spi msb f irst t ransaction msb lsb cs x sck sdo/sdi msb first spi transaction (mode 0 shown) when the spireverse is set to 1, the spi transactions are done in lsb first format, as shown in the next figure. f igure 21: spi lsb f irst t ransaction lsb msb cs x sck sdo/sdi lsb first spi transaction (mode 0 shown) 9.7 manual chip select control when the spimancs bit of the spiconfig register is set to 1, the active chip select line will stay at a logic low after the spi master mode transaction is completed, as shown in the following figure. f igure 22: spi m anual c hip select manual csx mode (spi mode 0 shown) *arrows indicate the edge where the data acquisition occurs ms b lsb sc k sdi sdo cs x note: csx stays low the chip select will remain at logic 0 until the spimancs bit is cleared by the software. 9.8 spi interrupts the spi can trigger three in terrupt sources that are handled by two interrupt vectors, as shown in the following table: t able 94: spi i nterrupt sources interrupt interrupt number interrupt vector spi tx empty int_1 000bh spi rx available spi rx overrun int_2 0013h the tx empty interrupt is set when the spi transmit buffer is ready to receive more data. a double buffer is used in the spi transmitter. once transmission begins (after a write to the spirxtx0 register), the data is transferred to the final transmission buffer. this frees up the spirxtx sfr register, raises the spitxempf flag of the status register and triggers an spi tx empty interrupt if enabled. the spi tx empty interrupt is enabled by setting the spitxeen bit of the spiconfig register to 1. the priority of the spi tx empty interrupt is set high in order to avoid buffer overrun in 32-bit spi transfers. the spi rx available interrupt is activated when receive data has been transferred from the spi rx buffer to the spirxtx register. the spirxtx register must be read by the processor before the next spi bus data sequence is completed. the spi rx available interrupt is enabled by setting the spirxaven bit of the spiconfig register to 1. the spirxavf flag of the spistatus register, when set to 1, indicates that data can be read. the spirxavf flag is automatically reset when the spirxtx0 register is read. the spi rx overrun interrupt indicates that an overrun condition has taken place. the spi rx overrun interrupt is enabled by setting the spirxoven bit of the spiconfig register to 1. the spirxovf flag of the spistatus register, when set to 1, indicates that a data collision has occurred. all the spi interface interrupt flags are active even if the associated interrupt is not activated and they can be monitored by the user program at any time. please consult the interrupt section for more details on the spi interface interrupts and their interaction with other peripherals
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 51 of 99 9.9 alternate cs3 functions for external spi devices which require the use of a load or a frame select signal, the VRS51L2070 can be configured to either generate an active low frame select or active high load signal when operating in master mode. 9.9.1 frame select signal on cs3 when the foncs3 bit of the spiconfig register is set to 1, the spi interface will generate an active low frame select pulse on the cs3 pin (see the following timing diagram). f igure 23: spi f rame s elect p ulse t iming frame select pulse (spi mode 0 shown) *arrows indicate the edge where the data acquisition occurs ms b lsb sc k sdi sdo cs3 cs x frame select pulse width = 1 / sys clk 9.9.2 load signal on cs3 when the spiloadcs3 bit of the spiconfig register is set to 1 and the fsoncs3 bit is cleared, an active low load signal will be generated on the cs3 line of the spi interface. f igure 24: spi l oad p ulse t iming load pulse (spi mode 0 shown) *arrows indicate the edge where the data acquisition occurs ms b lsb sc k sdi sdo cs3 cs x load pulse width = 1 / sys clk note that the frame select alternate function has priority over the load function. this means that if the fsoncs3 bit is set, the alternate function selected will be the frame select, independent of the value of the spiload bit. 9.10 spi activity monitoring the ability to monitor the stat e of communication of the spi interface can be useful in highly modular applications in which the spi interface is handled by interrupts. the spistatus register contains two flags that can be used to monitor the cs and ss signals of the spi interface. the spinocs bit of the spistatus register returns the logical and of all the spi cs lines of the VRS51L2070. if all the cs lines are inactive (logic high), the spi interface sets the spinocs to 1. the spinocs bit is used to verify that the spi interface is idle before reconfiguring it or starting a new transaction. the spinocs bit of the spistatus register is valid four system clock cycles after the spi transmission begins. this delay is independent of the spi transaction speed. as such, after a write operation to the spirxtx0 register, which will trigger a spi transaction in master mode, a nop instruction (1 cycle) must be added before the mov rn, spistatus instruction (3 cycles). the sspinval bit of the spistatus register returns the logic level on the ss pin. 9.11 spi tx underrun flag the spi interface provides an underrun condition flag that can be used to flag whether the software has failed to update transmission buffer in time for the next transfer. this is especially useful when the spi interface is used to transmit packets greater than 32 bits in length. if an underrun condition occurs, the spiunderf bit of the spi status register will be set to 1. this bit can be cleared by writing a 1 to the spiunderc bit of the spiconfig register. note that spi underrun monitoring is not linked to any of the spi interrupts, therefore, this flag can only be v manually by software 9.12 spi transaction size the standard spi protocol is based on 8-bit transactions. however, m any devices on the market, specifically a/d and d/a converters, require transactions greater than 8 bits. to communicate with these types of devices using a standard spi interface, the user has no choice but to send multiple 8-bit streams or to manipulate the i/os via software to emulate the timing control signals.
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 52 of 99 the VRS51L2070 spi interface supports 8-bit transactions and can also be configured to support transactions that measure 1 to 32 bits in both transmit and receive directions. the value written into the spisize register controls the transaction size. upon reset, the spi interface is configured for 8-bit transactions. t able 95:spi t ransaction s ize ? spisize sfr c3 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 1 1 1 bit mnemonic description 7:0 spisize[7:0] spi transaction size if < 32 : transaction size = spisize + 1 if >= 32: transaction size = (spisize *8) - 216 default transaction size = 8 bits four formulas control the spi transaction size: for transactions size <= 32 bits transaction size = spisize[7:0] +1 or spisize[7:0] = transaction size - 1 for transactions size > 32 bits transaction size = [ (spisize[7:0] * 8) ?216] or it can be expressed by: spisize[7:0] = [ transaction size + 216 ] 8 the following table provides examples: t able 96: t ransaction size vs . spisize[7:0] spisize[7:0] transaction size 0x07 8-bit 0x0b 12-bit 0x0d 14-bit 0x10 17-bit 0x17 24-bit 0x1f 32-bit 0x20 40-bit 0x21 48-bit 0x23 64-bit the transaction size must also be configured when the operating the spi interface in slave mode. 9.13 spi rx/tx data registers four sfr registers prov ide access to the spi interface?s receive and transmit data buffer. performing a write operation to the sp i rx/tx buffer transfers the data to the transmit portion of the spi interface, while a read operation reads the c ontents of the receive data buffer. the spi 32-bit receive and transmit data buffers are double buffered to minimize the risk of data collision and to achieve optimal performance. the spi rxtx0 register cont ains bits 7:0 of the spi interface rx/tx register. t able 97: spirxtx0 r egister content for normal and reversed t ransactions operation spi mode spirxtxx data is? msb first right justified read lsb first left justified msb first left justified write lsb first right justified when the spi is configured in master mode, writing to the spirxtx0 will trigger a dat a transmission. for this reason, when the transaction size is larger than 8 bits, the spirxtx0 register must be written last. t able 98:spi rx / tx0 d ata r egister ? spirxtx0 sfr c4 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description read: spi rxdata[7:0] right justified in normal mode, left justified in bit reversed mode reading this register, clears the spiavf and spirxovf flags 7:0 spirxtx0[7:0] write: spi txdata[7:0] left justified in normal mode, right justified in bit reversed mode in master mode, writing to spirxtx0 triggers the transmission
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 53 of 99 t able 99:spi rx / tx1 d ata r egister ? spirxtx1 sfr c5 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description read: spi rxdata[15:8] right justified in normal mode, left justified in bit reverse mode 7:0 spirxtx1[7:0] write: spi txdata[15:8] left justified in normal mode, right justified in bit reverse mode t able 100:spi rx / tx2 d ata r egister ? spirxtx2 sfr c6 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description read: spi rxdata[23:16] right justified in normal mode, left justified in bit reverse mode 7:0 spirxtx2[7:0] write: spi txdata[23:16] left justified in normal mode, right justified in bit reverse mode t able 101:spi rx / tx3 d ata r egister ? spirxtx3 sfr c7 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description read: spi rxdata[31:24] right justified in normal mode, left justified in bit reverse mode 7:0 spirxtx3[7:0] write: spi txdata[31:24] left justified in normal mode, right justified in bit reverse mode 9.14 spi data input /output the VRS51L2070 spi interface has the ability to perform data transactions in msb first mode or lsb first. the spireverse bit of the spistatus register controls whether the data will be transmitted mbs first or lsb first. upon device reset, the spireverse bit equals 0 and data is transmitted in msb first format. the spireverse bit state will also affect the data transmission and the data reception buffer structure as shown in the following diagrams. f igure 25: spi transaction s tandard m ode (spireverse = 0 : msb f irst ) outgoing transaction lsb msb spirxtx3 70 spi transmission (standard mode) spirxtx2 0 7 spirxtx1 0 7 spirxtx0 0 7 sdo pin spirxtx3 70 spi reception (standard mode) sdi pin spirxtx2 0 7 spirxtx1 0 7 spirxtx0 0 7 incoming transaction msb lsb f igure 26: spi transaction b it r everse m ode (spireverse = 1: lsb f irst ) spi reception (bit reversed mode) spirxtx3 70 spirxtx2 0 7 spirxtx1 0 7 spirxtx0 0 7 sdi pin incoming transaction lsb msb spi transmission (bit reversed mode) spirxtx3 70 sdo pin spirxtx2 0 7 spirxtx1 0 7 spirxtx0 0 7 outgoing transaction msb lsb the next tables gives examples of spi transmission and reception in different modes if the spi sdo pin is connected to the sdi pin. spisize = 0x0f (16 bit) / spireverse= 0 (msb first spitx [3:0] spirx [3:0] xx xx d3h 42h xx xx 42h d3h xx xx 54h a6h xx xx a6h 54h spisize = 0x0f (32 bit) / spireverse= 0 (msb first spitx [3:0] spirx [3:0] 45h a3h b2h df dfh b2h a3h 45h c3h 8ah 49h 24h 24h 49h 8ah c3h spisize = 0x0f (32 bit) / spireverse= 1 (lsb first spitx [3:0] spirx [3:0] 45h a3h b2h df dfh b2h a3h 45h c3h 8ah 49h 24h 24h 49h 8ah c3h
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 54 of 99 9.14.1 performing variable-bit data transmission for a variable-bit data transmission in master mode (when the data is not transmitted in multiples of 8 bits), the most significant bit of the data to be transmitted must first be placed at position 7 of the spirxtx0, with the remaining bits positioned as shown in the spi transaction figures on the previous page. for example if spisize = 0x0b and spireverse = 0, the data transaction will measure 12 bits, msb first. for the transmission to occur in the correct order, the lower 4 data bits must first be placed into bit positions 7:4 of the spirxtx1 register, with bits 11:8 written into bit position 7:0 of the spirxtx0 register. this will trigger the transmission. the following is a sequence of steps to transmit 12 bits of data contained in an integer variable called txmitdata . 1. clear the spirxtx3 and spirxtx2 registers (optional) 2. put the lower quartet of the 12-bit data (bits 3:0) into the upper quartet of the spirxtx1 register 3. write bit 7:0 of the 12-bit data into the spirxtx0 register 4. this will trigger a data transmission in c, this is expressed as follows: (?) spirxtx3 = 0x00; spirxtx2 = 0x00; spirxtx1 = (txmitdata << 4)&0xf0; //write the lower quartet of data //into the upper quartet of spirxtx1 register readflag = spirxtx0 //-dummy read the spi rx buffer to clear the rxav flag //(facultative if spinocs is monitored) spirxtx0 = dacdata >> 4; //writing to spirxtx0 will trigger the transmission for example to output 0x3a2 through the spi interface configured in master mode and msb first format, write 0x20 into the spirxtx1 sfr register and followed by 0xa2 into the spirxtx0 register. the reception of non multiple of 8 data when the spi interface is configured to msb first transaction is very straight forward as the data enters into the receiving buffer through the bit 0 of the spirxtx0 register and propagates towards the bit 7 of spirxtx3 register. 9.15 spi example programs 9.15.1 uart to spi data transmission example //---------------------------------------------------------------------------------------// // spi transmit example.c // //--------------------------------------------------------------------------------------// // // this program sends characters received on the uart to the spi interface // //--------------------------------------------------------------------------------------// #include <VRS51L2070_sdcc.h> //----global variables ------// int cptr = 0x00; //general purpose counter // --- function prototypes void txmit0( unsigned char charact); void uart0config(void); //-------------------------------------------------------// // main function // //-------------------------------------------------------// void main (void){ char value = 0x00; //general purpose variable periphen1 = 0xc0; //enable spi interface intconfig = 0x02; //erase bypass global int, before configuring the int0 pin event //this fix inadvertent int0 interrupt that occurs when //int0 cause is set to rising edge intsrc1 = 0x01; //int0 vector source = int0 pin intpinsens1 = 0x01; //set int0 sensitive on edge(1) or level(0) intpininv1 = 0x00; //set int0 pin sensitivity on normal level(0) / inverted (1) inten1 = 0x01; //enable int0 (bit0) interrupt intconfig = 0x01; //enable global interrupt while(1); }//end of main //---------------------------------------------------------------------------------------// //----------------------------- interrupt functions -------------------------------// //---------------------------------------------------------------------------------------// //------------------------------------------------------------------------------// // interrupt int0 // // send character received on the spi interface // //-----------------------------------------------------------------------------// void int0interrupt(void) interrupt 0 { //-- send "ext int0 received" on uart0 cptr = 0x00; // init cptr to pint to message beginning inten1 = 0x00; /disable interrupts spictrl = 0xe1; //spi clk = div by 256 //spi cs0 active //spi mode 0 //spi master spisize = 0x07; //spi size = 8bit spiconfig = 0x10; //load on cs3 spirxtx0 = s0buf; //send data byte on spi interface inten1 = 0x01; //enable interrupt int0 }//end of int0 interrupt
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 55 of 99 9.16 spi interface to 12-bit adc and dac the following example program shows the initialisation and use of the spi module of the VRS51L2070 as an interface to serial adc and dac. .//----------------------------------------------------------------------------------------------------------------------// // VRS51L2070_generic_spi_based_adc_dac_interf1.c //----------------------------------------------------------------------------------------------------------------------// // description: // this program demonstrates the configuration and use of the spi interface // for interface to typical serial 12 bit a/d and d/a converters. // the program read the a/d and output the read value out on a d/a converter // to perform the conversion the adc requires 16 clock cycles and // the dac requires 12 clock cycles. //----------------------------------------------------------------------------------------------------------------------// #include <VRS51L2070_sdcc.h> //---functions prototypes void readgen_12bit_adc(void); //gen_12bit_adc read void writegen_12bit_dac(unsigned int ); //gen_12_bit_dac write void v2kdelay1ms(unsigned int); //standard delay function // global variables definitions idata unsigned char cptr = 0x00; unsigned int at 0x0060 adcdata= 0x00; //--------------------------------------------------------------------------------------------// // main function //--------------------------------------------------------------------------------------------// void main (void) { do{ readgen_12bit_adc(); //read the a/d converter writegen_12bit_dac(adcdata); //write into the d/a converter }while(1); }// end of main //--------------------------------------------------------------------------------------------// // name: readgen_12bit_adc //--------------------------------------------------------------------------------------------// // description: // read the gen_12bit_adc a/d // adc is connected to spi interface using cs0 // max clk speed is 3.2mhz, fosc = 40mhz assumed //--------------------------------------------------------------------------------------------// void readgen_12bit_adc() { int cptr = 0x00; char readflag = 0x00; //spi configuration section //(can be moved to main function if only one device is connected to the spi interface) //make sure the spi interface is activated periphen1 |= 0xc0; //--wait activity stops on the spi interface (monitor spinocs) while(!(spistatus &= 0x08)); spictrl = 0x65; //spiclk = /16 (2.5mhz) //cs0 active //spi mode 1 phase = 1, pol = 0 //spi master mode spiconfig = 0x40; //spi chip select is automatic //clear spiundefc flag //spiload = 0 -> manual cs3 behaviour //no spi interrupt used spistatus = 0x00; //spi transactions are in msb first format spisize = 0x0e; //spi transaction size are 15 bit //-dummy read the spi rx buffer to clear the rxav flag readflag = spirxtx0; //-perform the spi read spirxtx0 = 0x00; //writing to the spirxtx0 will trigger the spi //transaction while(!(spistatus &= 0x02)); //wait for the spi rx av flag being set /* // -- it is possible to monitor the spinocs flag instead of the spirxav flag //the code piece below shows how to do it. however in that case, //no that the reading of the spistatus register must be done at //least 4 system clock cycles after the write operation to the spirxtx0 register //-wait for spinocs flag have time to be updated _asm nop; _endasm; while(!(spistatus &= 0x08)); //wait activity stops on the spi interface */ //read spi data adcdata= (spirxtx1 << 8); adcdata+= spirxtx0; adcdata&= 0x0fff; //isolate the 12 lsb of the read value }//end of readgen_12bit_adc //--------------------------------------------------------------------------------------------// // name: writegen_12bit_dac //--------------------------------------------------------------------------------------------// // description: // write 12bit data into the gen_12bit_dac device // adc is connected to spi interface using cs1 // max clk speed is 12.5mhz, fosc = 40mhz assumed // we will set the spi prescaler to sysclk / 8 //--------------------------------------------------------------------------------------------// void writegen_12bit_dac(unsigned int dacdata) { char subdata = 0x00; char readflag = 0x00; periphen1 |= 0xc0; //make sure the spi interface is activated //--wait activity stops on the spi interface (monitor spinocs) while(!(spistatus &= 0x08)); //spi configuration section //can be moved to main function if only one device is connected to the spi interface spictrl = 0x4d; //spiclk = /8 (mhz) //cs1 active //spi mode 1 phase = 1, pol = 0 //spi master mode spiconfig = 0x40; //spi chip select is automatic //clear spiundefc flag //spiload = 0 -> manual cs3 behaviour //no spi interrupt used spistatus = 0x00; //spi transactions are in msb first format spisize = 0x0b; //spi transaction size are 12 bit //-format the 12 bit data so data bit 11 is positioned on bit 7 of spirxtx0 // and data bit 0 is positioned on bit 4 of spirxtx1 and perform the spi write operation dacdata &= 0x0fff; //make sure dacdata is <= 0fffh (12 bit) spirxtx3 = 0x00; spirxtx2 = 0x00; spirxtx1 = (dacdata << 4)&0xf0; //-dummy read the spi rx buffer to clear the rxav flag // (facultative if spinocs is monitored) readflag = spirxtx0; spirxtx0 = dacdata >> 4; //writing to spirxtx0 will trigger the transmission //--wait the spi transaction completes // this section can be omitted if a check of activity on the spi interface // is made before each access to it in master mode //wait for the spi rx av flag being set while(!(spistatus &= 0x02)); // -- it is possible to monitor th e spinocs flag instead of the spirxav flag //the code piece below shows how to do it. however in that case, //no that the reading of the spistatus register must be done at //least 4 system clock cycles after the write operation to the spirxtx0 register /* //-wait for spinocs flag have time to be updated _asm nop; _endasm; //--wait activity stops on the spi interface (monitor spinocs flag) while(!(spistatus &= 0x08)); */ }//end of writegen_12bit_dac
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 56 of 99 10 i2c interface the VRS51L2070 includes an i2c interface that can operate in master and slave mode. in master mode, the communication speed on the i2c is programmable, optimizing communication between i2c-based devices. long or heavily loaded i2c bus applications are likely to require slower communication speeds. 10.1 i2c bus pull-up resistors by definition, the i2c requir es that the user include external pull-up resistors on the scl and sda lines. the pull-up voltage can be either 3.3 or 5 volts. note that the VRS51L2070 i/os are 5v?tolerant making it possible to interface 5v, i2c-based devices with the VRS51L2070. the proper value for the pull-up resistor and the proper communication speed depend on bus characteristics such as length and capacitive load. note that the pull-up resistor value should not be below 1.25k ohms if running the i2c bus at 5v; and 750 ohms if operating at 3.3v. this is required in order to limit the current to 4ma (maximum current of the i/o port connected to the i2c interface). 10.2 i2c phases the i2c protocol includes five phases: 1. idle (scl = 1, sda = 1) 2. device id 3. device id acknowledge 4. data 5. data acknowledge the VRS51L2070 i2c interface has provisions to monitor activity on the i2c bus, particularly the data acknowledge phase of a i2c tr ansaction. there is also a mechanism that enables the detection of communication errors. 10.3 i2c control and status registers four sfr registers are dedica ted to the i2c interface. the i2c configuration register i2cconfig enables: ? selection of master or slave operation ? forcing a start condition after an acknowledge phase ? manual control of the scl line ? activation of the master arbitration monitoring mechanism ? interrupt activation t able 102:i2c c onfiguration register - i2cconfig sfr d1 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 1 0 0 bit mnemonic description 7 mastrarb master lost arbitration and mechanism and interrupt 0 = deactivated 1 = master lost arbitration monitoring and interrupt is enabled 6 i2crxoven i2c rx overrun interrupt enable 0 = i2c rx overrun interrupt is deactivated 1 = i2c rx overrun interrupt is enabled 5 i2crxaven i2c rx available interrupt enable 0 = i2c rx available interrupt is deactivated 1 = i2c rx available interrupt is enabled 4 i2ctxeen i2c tx empty interrupt enable 0 = i2c tx empty interrupt is deactivated 1 = i2c tx empty interrupt is enabled 3 i2cmastart i2c master create start 0 = no start condition is created after data acknowledge phase 1 = master will create a start condition after the next data acknowledge phase this bit will be cleared when the i2c is idle 2 i2cscllow keep the i2c scl low setting this bit to 1 will force the scl line low. this bit is read by the i2c interface when it enters in the data i2c. this bit must not be set during the acknowledge phase. 1 i2crxstop i2c reception stop 0 = the i2c received will acknowledge after receiving a byte 1 = the i2c receiver will not acknowledge after the next data byte is received 0 i2cmode i2c mode enable 0 = i2c interface operates in slave mode 1 = i2c interface operates in master mode the i2cmode bit of the i2cconfig register, when set to 1, will configure the i2c interface as a master. in master mode, the VRS51L2070 i2c interface controls the i2c bus and initiates transmission and reception transactions. in master mode, the i2c interface also controls the communication speed. clearing the i2cmode bit of the i2cconfig register will configure the i2c interfac e as a slave. slave mode can be useful for applications in which the VRS51L2070 operates as a peripheral in a host- controlled system.
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 57 of 99 when in master mode, the i2c interface can be forced to generate a start condition after the next data acknowledge phase. this is done by setting the i2cmastart bit to 1. when the mastrarb bit is set to 1, communications of the i2c will be monitored and an interrupt will be generated if arbitration with slave devices on the bus is lost. the interrupt flag associated with this process is the i2cerror bit of the i2cstatus register. if the i2crxstop bit is set to 1, the i2c interface will not acknowledge after reception of the next byte, but will generate a stop condition instead. this will, in effect, end the transaction with the master device. when the i2c interface is configured as a master and the i2cscllow bit of the i2cconfig register is set to 1, the scl line will be driven low during the next data acknowledge phase. this feature enables the user to add the equivalent of wait states to the transfer in order to support ?slow? devices connected to the i2c bus. the i2c interface includes support for four interrupt conditions via two interrupt vectors. ? rx data available ? rx overrun ? tx empty ? master lost arbitration the following table summarizes the possible interrupt sources at the i2c interface level. t able 103: i2c i nterrupt sources i2c interrupt i2cconfig bit (set to 1 to activate) interrupt vector rx data available i2crxaven 4bh (int 9) rx overrun i2crxoven 0x4b (int 9) tx empty i2ctxeen 0x4b (int 9) master lost arbitration mastrarb 0x53 (int 10) to activate the i2c interface interrupts, the corresponding enable bit of the i2cconfig register must be set to 1. this will allow the i2c interrupt to propagate to the VRS51L2070?s interrupt controller. in order for the i2c interrupt to be recognized by the processor, the corresponding bit of the inten2 and intsrc2 registers must be configured accordingly. see the VRS51L2070 interrupt section for more details. 10.4 i2c timing control register the i2ctiming register controls the communication speed when the i2c interface is configured in master mode. when in slave mode, it defines the values of the setup and hold times. t able 104:i2c t iming register - i2ctiming sfr d2 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 1 1 0 0 bit mnemonic description 7:0 i2ctiming[7:0] i2c master/slave timing configuration register see below the following formulas demonstrate the impact of the i2ctiming value on the communication speed and setup/hold times. in master mode: scl period = i2cclk 32*( i2ctiming[7:0] + 1) the following table provides examples of the i2ctiming values and the corresponding communication speed: t able 105: i2c communication speed vs . i2ctiming register value (f osc = 40mh z ) i2ctiming i2c com speed 00h 1.25 mhz 02h 416.77 khz 0ch (reset) 96.15 khz 7ch 10khz ffh 4.88khz in slave mode: set-up/hold time = i2cclkperiod * i2ctiming[7:0] in this case, the precision is: 2 x i2cclkperiod t able 106: i2c s etup and h old t ime vs . i2ctiming register value (f osc = 40mh z ) i2ctiming setup/hold time 00h 0 us 0ch 0.3 us ffh 6.38 us
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 58 of 99 10.5 i2c slave device id and advanced configuration when operating in slave mode, the device id on the i2c interface is configurable. the seven upper bits of the i2cidcfg register contain the user-selected device id. bit 0 of the i2cidcfg register has two distinct roles. the i2cavcfg provides advanced control on i2c interface operations. t able 107:i2c d evice id c onfiguration - i2cidcfg sfr d3 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 i2cid[6:0] slave i2c device id as selected by user read: indicates that the i2c slave has received id that is different from the i2cid. this flag is cleared when the received id corresponds with the i2cid 0 i2cadvcfg writing: slave mode: 1= the i2crxav flag is raised when the i2c slave receives a device id master mode: 1 = enables monitoring of the scl line in wait state mode in case of mismatch of the scl line vs. the expected value when the i2c interface operates in master mode and the i2cadvcfg is cleared, the i2c interface module will continuously monitor the scl line. if the slave device drives the scl line into an incorrect state, the i2c interface will enter wait state mode until the slave device releases the scl line. this mode can be useful for a i2c communication debug. when the i2cadvcfg bit is set, no monitoring of the scl line will be executed by the i2c module and the transaction will proceed independently of the level of the scl line. when the VRS51L2070 i2c interface module is configured as a slave, reading the i2cadvcfg bit as 1 indicates that the id received does not match the current device id. this bi t will be cleared when the correct device id is received. in slave mode, writing a 1 into the i2cadvcfg bit of the i2cidcfg register will make the i2crxavf flag of the i2cstatus register remain at 0, after the device id is received. if the i2ca dvcfg bit is cleared, the i2crxavf flag will be set either when a correct device id, or when valid data, are received. 10.6 i2c status register monitoring of the i2c interface can be done via the i2cstatus register located at sfr address d4h. the i2cstatus register is read only and values written into that location have no effect. the i2cerror flag indicates that an error condition occurred on the i2c interface. in master mode, the i2cerror flag will be set by the VRS51L2070 i2c interface, if it lo ses bus arbitration. in slave mode, if an unexpected stop is received, the i2cerror flag will be set. the i2cerror flag will be automatically reset by the i2c interface the next time it exits an idle state. if the i2cnoack flag is set to 1, it signifies that the slave device did not acknowle dge the last data byte it received. the i2c interface also monitors the synchronization of the sda line. when synchronization is lost, the i2csdasync bit of the i2cs tatus register will be set by the i2c interface. the i2csdasync bit of the i2cstatus register returns the value of the sda line the moment a read operation is performed on the i2cstatus register. the i2cackph bit when set, indicates that the i2c interface is currently in the data acknowledge phase. reading of the i2csdasync and i2cckph bits can be used to determine whether the slave device has acknowledged. if both bits are set to 1 at a given time, the slave device did not acknowledge.
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 59 of 99 t able 108: i2c s tatus register - i2cstatus sfr d4 h 7 6 5 4 3 2 1 0 r r r r r r r r 0 0 1 0 1 0 0 1 bit mnemonic description slave mode error flag: 0 = no error 1 = indicates that the i2c interface received an unexpected stop this flag is reset the next time the i2c interface exits from an idle state (see below) 7 i2cerror master mode 0 = no arbitration error 1 = i2c interface has lost arbitration this flag is reset the next time the i2c interface exits from an idle state (see below) 6 i2cnoack i2c acknowledge error flag 0 = acknowledge was received normally 1 = no acknowledge was received during the last acknowledge phase this flag is reset the next time the i2c interface exit from the idle state (see below) 5 i2csdasync i2c sda sync status flag 0 = sda pin in not in sync 1 = sda pin is in sync 4 i2cackph when set, this flag indicates that the i2c interface is in ?data acknowledge phase.? 5 phases of i2c protocol: 1. idle 2. device id 3. device id acknowledge 4. data 5. data acknowledge 3 i2cidlef i2c is idle 0 = i2c interface is communicating 1 = i2c interface is inactive (idle phase) and the scl and sda lines are high 2 i2crxovf i2c rx overrun interrupt flag 0 = no i2c rx overrun condition detected 1 = i2c data collision occurred 1 i2crxavf i2c rx available interrupt flag 0 = i2c receive buffer is empty 1 = data is present in the i2c rx buffer 0 i2ctxempf i2c tx empty interrupt flag 0 = i2c transmit buffer is full 1 = i2c transmit buffer is ready to receive new data when set, the i2cidlef indicates that the i2c bus is idle and that a transaction can be initiated. before initiating an i2c data transfer, it is recommended to check the state of the i2cidlef bit. this bit indicates whether or not a data transfer is currently in progress. when new data is received in the i2c receive buffer, the i2crxavf interrupt flag w ill be set. data must be retrieved from the i2crxtx buffer before the reception of the next data byte is complete. the i2crxovf flag when set, indicates an overrun condition in the i2c interface receive buffer and the data is potentially corrupted. the i2ctxempf interrupt flag is set by the i2c interface when the transmit data buffer is ready to receive another data byte. 10.7 i2c transmit/receive register the i2c interface transmit and receive buffers are accessed via the i2crxtx sfr register, which is accessible at sfr address d5h. t able 109:i2c data rx / tx r egister i2crxtx - sfr d5 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description read: i2c receive buffer reading the i2crxtx register will clear the i2crxav and i2crxov flags 7:0 i2crxtx[7:0] write: i2c transmit buffer writing into the i2crxtx register will trigger the transmission 10.8 i2c interface alternate pins upon reset, the i2c interface signal scl and sda are mapped into pins p3.4 and p3.5, respectively. however it is also possible to map these signal into the p1.6 and p1.7 pins. bit 5 of the deviomap register (sfr e1h) is used to configure the mapping of the i2c interface at the i/o level, as shown in the following table: t able 110: i2c module mapping deviomap.5 bit value scl mapping sda mapping 0 (reset) p3.4 p3.5 1 p1.6 p1.7
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 60 of 99 10.9 i2c interface example programs the following programs provide example code for i2c control of eeprom devices //----------------------------------------------------------------------------// // vrs2k-i2c _eeprom.c // //----------------------------------// // // this example program demonstrate the use of the i2c // interface to perform basic read and write operations on a // standard eeprom device. //----------------------------------------------------------------------------// #include <VRS51L2070_sdcc.h> sfr at 0xd1 calsosc; //self oscillator calibration //----global variables ------// int cptr = 0x00; //general purpose counter // --- function prototypes char eerandomread(char,int); char eerandomwrite(char, char, int); void waittxemp(void); void waitrxav(void); void waiti2cidle(void); void wait(); //------------------------------------------------------------// //--------------- main function -------------------// //------------------------------------------------------------// void main (void){ periphen1 = 0x20; //enable i2c interface intconfig = 0x02; //erase bypass global int, before configuring the int0 pin event //this fix inadvertent int0 interrupt that occurs when //int0 cause is set to rising edge intsrc1 = 0x01; //int0 vector source = int0 pin intpinsens1 = 0x01; //set int0 sensitive on edge(1) or level(0) intpininv1 = 0x00; //set in t0 pin sensitivity on normal level(0) / inverted (1) inten1 = 0x01; //enable int0 (bit0) interrupt intconfig = 0x01; //enable global interrupt while(1); }//end of main //----------------------------------------------------------------------------// //------------------------ interrupt functions -------------------------// //----------------------------------------------------------------------------// //----------------------------// //---- interrupt int0 ----// //---------------------------// void int0interrupt(void) interrupt 0 { char x; //-- send i2c stuff cptr = 0x00; // init cptr to pint to message beginning inten1 = 0x00; //disable interrupts x = eerandomwrite(0xa0, 0x36, 0x0206); //perform write operation delay1ms(100); x = eerandomread( 0xa0, 0x0206); //perform read operation inten1 = 0x01; //enable interrupt int0 }//end of int0 interrupt //--------------------------------------------------------------------------// //------------------------ individual functions ---------------------// //--------------------------------------------------------------------------// //---------------------------------------------------------------------------------// //---- function eeran domread(char eeidw,int address) -----// //---------------------------------------------------------------------------------// char eerandomread(char eeidw,int address){ i2ctiming = 0x20; // i2c clock speed = about 100khz i2cconfig = 0x01; //i2c is master i2crxtx = eeidw; //write i2c device id + w waittxemp(); i2crxtx = address >> 8; //write i2c adrsh waittxemp(); i2crxtx = address; //write i2c adrsl //--wait for i2c idle (this will generate a stop) waiti2cidle(); //--start a preset adrs read (this will generate a start) i2crxtx = eeidw+1; //write i2c device id + r waittxemp(); i2cconfig |= 0x02; //force i2c to not acknowledge after //receiving the next data byte waitrxav(); //wait for rx available bit, this will trigger i2c reception return i2crxtx; //return data byte }//end of eerandomread //--------------------------------------------------------------------------------------------------// //----- function eerandomwrite(char eeid,char data, int address) ----------// //--------------------------------------------------------------------------------------------------// char eerandomwrite(char eeidw, char eedata, int address){ i2ctiming = 0x20; // i2c clock speed = about 100khz i2cconfig = 0x01; //i2c is master i2crxtx = eeidw; //write i2c device id + w waittxemp(); i2crxtx = address >> 8; //write i2c device id + w waittxemp(); i2crxtx = address; //write i2c device id + w waittxemp(); i2crxtx = eedata; //write i2c device data waittxemp(); return i2crxtx; //return data byte }//end of eerandomwrite //--------------------------------------------------// //-------- function waittxemp() ----------// //--------------------------------------------------// void waittxemp() { wait(); do{ userflags = i2cstatus; userflags &= 0x01; //isolate the i2c tx empty flag }while( userflags == 0x00); //wait for i2c tx empty }//end of void waittxemp() //--------------------------------------------------// //-------- function waitrxav() ------------// //--------------------------------------------------// void waitrxav() { wait(); do{ userflags = i2cstatus; userflags &= 0x02; //isolate the i2crxav flag }while( userflags == 0x00); //wait for i2c rx available }//end of void waitrxav() //---------------------------------------------------// //-------- function waiti2cidle() ---------// //---------------------------------------------------// void waiti2cidle() { wait(); do{ userflags = i2cstatus; userflags &= 0x08; //isolate the i2c idle flag }while( userflags == 0x00); }//end of void waiti2cidle() //----------------------------------------// //-------- function wait() ----------// //----------------------------------------// void wait(){ char i=0; while (i<25) {i++;}; }
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 61 of 99 11 pulse width modulators (pwms) the VRS51L2070 includes eight independent pwm channels, each based on a 16-bit timer. all of the pwm modules can be configured to operate as a regular pwm with adjustable resolution, or as a general purpose 16-bit timer. the pwmen register is used to enable the different pwm modules. t able 111: pwm e nable register - pwmen sfr aa h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 pwm7en pwm7 channel enable 0 = pwm channel 7 is deactivated 1 = pwm channel 7 is activated 6 pwm6en pwm6 channel enable 0 = pwm channel 6 is deactivated 1 = pwm channel 6 is activated 5 pwm5en pwm5 channel enable 0 = pwm channel 5 is deactivated 1 = pwm channel 5 is activated 4 pwm4en pwm4 channel enable 0 = pwm channel 4 is deactivated 1 = pwm channel 4 is activated 3 pwm3en pwm3 channel enable 0 = pwm channel 3 is deactivated 1 = pwm channel 3 is activated 2 pwm2en pwm2 channel enable 0 = pwm channel 2 is deactivated 1 = pwm channel 2 is activated 1 pwm1en pwm1 channel enable 0 = pwm channel 1 is deactivated 1 = pwm channel 1 is activated 0 pwm0en pwm0 channel enable 0 = pwm channel 0 is deactivated 1 = pwm channel 0 is activated the following figure provides an overview of the pwm modules. f igure 27: pwm modules overview pwmldpol = 1 pwm timer x cl r pwmx mid pwmx end pwmclrall pwmx pin 0 1 < pwm mid > pwm mid > pwm end pwmtmrfx pwmtmrpr div ratio: sys clk / 1 downto sys clk / 16384 sys clk 015 pwmldpolx pwmxtmrenx to others pwm modules 11.1 pwm mid and end registers each pwm module includes two 16-bit registers: o pwm mid value register o pwm end value register the pwm mid register is a 16-bit register that configures the point at which the pwm output will change it?s polarity. the pwm end register is a 16-bit register that defines the maximum pwm internal timer count value, after which it rolls over to 0000h. see the following timing diagram. f gure 28: pwm p olarity setting start 0000h pwm mid value pwm end value cycle 1 cycle 2 pwmldpol = 0 pwmldpol = 1 pwm timer roll over here and the cycle repeats this configuration allows the user to adjust the resolution of the pwm up to 16 bits. access to the pwm internal registers and the pwm configuration is handled by the pwmcfg register located at address a9h.
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 62 of 99 t able 112:pwm c onfiguration register - pwmcfg sfr a9 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 - 6 pwmwait pwm waits before loading new configuration 0 = new pwm configuration is loaded at the end of pwm cycle 1 = the update of the pwm configuration only occurs when the end of the pwm is reached and the bit is set to 0 5 pwmclrall pwm clears all channels 0 = no action 1 = simultaneously clears all the flags and all the pwm channel timers this bit is automatically cleared by hardware 4 pwmlsbmsb pwm lsb/msb select 0 = selected pwm lsb sfr is addressed 1 = selected pwm msb sfr is addressed 3 pwmmidend pwm mid/end register 0 = selected pwm mid sfr is addressed 1 = selected pwm end sfr is addressed 2:0 pwmch[2:0] pwm channel select 000 = pwm0 on p2.0 (p5.0) 001 = pwm1 on p2.1 (p5.1) 010 = pwm2 on p2.2 (p5.2) 011 = pwm3 on p2.3 (p5.3) 100 = pwm4 on p2.4 (p5.4) 101 = pwm5 on p2.5 (p5.5) 110 = pwm6 on p2.6 (p5.6) 111 = pwm7 on p2.7 (p5.7) the pwm channels are configured one at the time. this topology has been adopted in order to minimize the number of sfr register s required to access the pwm modules. in applications where multiple pwm channels need to be configured simultaneous ly, the user can set the pwmwait bit of the pwmcfg register, configure each one of the pwm channels, and then clear the pwmwait bit. the pwm configurations will then be updated at the end of the next pwm cycle, after the pwmwait bit has been cleared. t able 113:pwm d ata r egister sfr ac h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 pwmdata[7:0] pwm data register the pwm data register se rves to configure the selected channel msb/lsb value of either the mid or end point, as specified in the pwmcfg register. the pwmidx defines the actual timer value and the pwmend defines the maximum timer count value before it rolls over. the pwmldpol register controls the output polarity of each one of the pwm modules or clears the timer?s value when the pwm modules operate as general purpose timers. t able 114:pwm p olarity and config l oad s tatus ? pwmldpol ab h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description read: 0 = last configuration has been loaded in pwm 1 = last configuration has not been loaded 7 pwmldpol7 write in pwm mode 0 = pwm 7 cycle starts with a low level 1 = pwm 7 cycle starts with a high level in timer mode 0 = no action 1 = pwm timer 7 value is cleared to 0 read: 0 = last configuration has been loaded in pwm 1 = last configuration has not been loaded 6 pwmldpol6 write in pwm mode 0 = pwm 6 cycle starts with a low level 1 = pwm 6 cycle starts with a high level in timer mode 0 = no action 1 = pwm timer 6 value is cleared to 0 read: 0 = last configuration has been loaded in pwm 1 = last configuration has not been loaded 5 pwmldpol5 write in pwm mode 0 = pwm 5 cycle starts with a low level 1 = pwm 5 cycle starts with a high level in timer mode 0 = no action 1 = pwm timer 5 value is cleared to 0 read: 0 = last configuration has been loaded in pwm 1 = last configuration has not been loaded 4 pwmldpol4 write in pwm mode 0 = pwm 4 cycle starts with a low level 1 = pwm 4 cycle starts with a high level in timer mode 0 = no action 1 = pwm timer 4 value is cleared to 0 read: 0 = last configuration has been loaded in pwm 1 = last configuration has not been loaded 3 pwmldpol3 write in pwm mode 0 = pwm 3 cycle starts with a low level 1 = pwm 3 cycle starts with a high level in timer mode 0 = no action 1 = pwm timer 3 value is cleared to 0 read: 0 = last configuration has been loaded in pwm 1 = last configuration has not been loaded 2 pwmldpol2 write in pwm mode 0 = pwm 2 cycle starts with a low level 1 = pwm 2 cycle starts with a high level in timer mode 0 = no action 1 = pwm timer 2 value is cleared to 0 1 pwmldpol1 read: 0 = last configuration has been loaded in pwm 1 = last configuration has not been loaded
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 63 of 99 write in pwm mode 0 = pwm 1 cycle starts with a low level 1 = pwm 1 cycle starts with a high level in timer mode 0 = no action 1 = pwm timer 1 value is cleared to 0 read: 0 = last configuration has been loaded in pwm 1 = last configuration has not been loaded 0 pwmldpol0 write in pwm mode 0 = pwm 0 cycle starts with a low level 1 = pwm 0 cycle starts with a high level in timer mode 0 = no action 1 = pwm timer 0 value is cleared to 0 11.2 pwm module cl ock configuration register one system clock prescaler is associated with pwm modules 0 to 3, while another is associated with pwm modules 4 to 7. the pwm clock prescalers enables the pwm output frequency to be adjusted to match specific application needs, if required. the pwm clock prescalers are configured via the pwmclkcfg register. the four upper bits of this register control the clock for pmm modules 4 to 7, and the four lower bits control the clock source for pwm modules 0 to 3. the pwm module clock configur ation register controls the prescale value applied to the pwm modules? input clock, when the pwm modules are configured to operate as either pwms or general purpose timers. t able 115: pwm clock p rescaler c onfiguration r egister - pwmclkcfg af h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:4 u4pwmclk3[3:0] pwm timer 7, 6, 5,:4 clock prescaler * see table below 3:0 l4pwmclk3[3:0] pwm timer 3, 2, 1,:0 clock prescaler * see table below the following table shows t he system clock division factor applied to the pwm modules for a given pwmclkcfg nibble. t able 116: pwm p rescaler values u4/l4pwmclk value (4 bit) clock prescaler u4/l4pwmclk value (4 bit) clock prescaler 0000 sys clk / 1 1000 sys clk / 256 0001 sys clk / 2 1001 sys clk / 512 0010 sys clk / 4 1010 sys clk / 1024 0011 sys clk / 8 1011 sys clk / 2048 0100 sys clk / 16 1100 sys clk / 4096 0101 sys clk / 32 1101 sys clk / 8192 0110 sys clk / 64 1110 sys clk/ 16384 0111 sys clk / 128 1111 sys clk/ 16384 11.3 pwm alternate mapping bit 6 of the deviomap register (sfr e1h) controls the mapping of the pwm module outputs, as shown in the following table: t able 117: pwm modules output mapping deviomap.6 bit value pwm 7-0 0 (reset) p2.7 ? p2.0 1 p5.7 ? p5.0 note that the pwm5 and pwm6 outputs have priority over the t0ex and t1ex inputs.
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 64 of 99 11.4 pwm examples program 11.4.1 pwm basic configuration the following example program shows the basic configuration of pwm modules #0, 1,2, 4 & 5 //-------------------------------------------------------------------------------------------------------------// // VRS51L2070-pwm_basic_sdcc.c // ////////////////////////////// // // description: VRS51L2070 pwms basic initialization demonstration program. // configure pwm0 as 8 bit resolution (25% duty) // configure pwm1 as 12 bit resolution (50% duty) // configure pwm2 as 16 bit resolution (75% duty) // configure pwm4 as 8 bit resolution and prescaler = 4 (25% duty) // configure pwm5 as 16 bit resolution and prescaler = 4 (75% duty) //-------------------------------------------------------------------------------------------------------------// // rev 1.0 // date: june 2005 //------------------------------------------------------------------------------------// #include <VRS51L2070_sdcc.h> // --- function prototypes void delay(unsigned int); void main (void) { periphen2 = 0x02; //enable pwm sfr //clear all pwm channels pwmcfg = 0x20; // configure the pwm prescaler pwmclkcfg = 0x20; // apply a clock prescaler (div / 4) on pwm 7:4 // configure pwm polarity pwmpol = 0x00; //set all pwm in normal polarity //pwm output = 0 until //pwmmid value is reached //---------------------------------// //configure pwm0 end value = 0x00ff (8bit) pwmcfg = 0x58; //point to pwm0 end msb pwmdata = 0x00; //set max count msb = 0xff pwmcfg = 0x48; //point to pwm0 end lsb pwmdata = 0xff; //set pwm mid msb = 0x00 (8bit) //configure pwm0 mid value (duty = 25%) pwmcfg = 0x50; //point to pwm0 mid msb pwmdata = 0x00; //set pwm mid msb = 0x00 pwmcfg = 0x40; //point to pwm0 mid lsb pwmdata = 0xbf; //set pwm mid lsb = 0xbf //---------------------------------// //configure pwm1 end value = 0x0fff (12bit) pwmcfg = 0x59; //point to pwm1 end msb pwmdata = 0x0f; //set max count msb = 0x0f pwmcfg = 0x49; //point to pwm1 end lsb pwmdata = 0xff; //set max count = 0xff //configure pwm1 mid value (duty = 50%) pwmcfg = 0x51; //point to pwm0 mid msb pwmdata = 0x08; //set pwm mid msb = 0x08 pwmcfg = 0x41; //point to pwm0 mid lsb pwmdata = 0x00; //set pwm mid lsb = 0x00 //---------------------------------// //configure pwm2 end value = 0xffff (16bit) pwmcfg = 0x5a; //point to pwm2 end msb pwmdata = 0xff; //set max count msb = 0xff pwmcfg = 0x4a; //point to pwm2 end lsb pwmdata = 0xff; //set max count = 0xff //configure pwm2 mid value (duty = 75%) pwmcfg = 0x52; //point to pwm2 mid msb pwmdata = 0x40; //set pwm mid msb = 0x04 pwmcfg = 0x42; //point to pwm2 mid lsb pwmdata = 0x00; //set pwm mid lsb = 0x00 //---------------------------------// //configure pwm4 end value = 0x00ff (8 bit) (clock prescaler = 4) pwmcfg = 0x5c; //point to pwm4 end msb pwmdata = 0x00; //set max count msb = 0xff pwmcfg = 0x4c; //point to pwm4 end lsb pwmdata = 0xff; //set max count lsb = 0xff //configure pwm4 mid value (duty = 25%) pwmcfg = 0x54; //point to pwm4 mid msb pwmdata = 0x00; //set pwm mid msb = 0x00 pwmcfg = 0x44; //point to pwm4 mid lsb pwmdata = 0xbf; //set pwm mid lsb = 0xbf //---------------------------------// //configure pwm5 end value = 0xffff (16bit) (clock prescaler = 4) pwmcfg = 0x5d; //point to pwm5 end msb pwmdata = 0xff; //set max count msb = 0xff pwmcfg = 0x4d; //point to pwm5 end lsb pwmdata = 0xff; //set max count = 0xff //configure pwm5 mid value (duty = 75%) pwmcfg = 0x55; //point to pwm5 mid msb pwmdata = 0x40; //set pwm mid msb = 0x04 pwmcfg = 0x45; //point to pwm5 mid lsb pwmdata = 0x00; //set pwm mid lsb = 0x00 //enable pwm0, pwm1, pwm2, pwm4 & pwm5 modules pwmen = 0x37; pwmcfg &= 0x1f; //clear the pwmwait bit to initiate //the pwms operation while(1); }// end of main 11.4.2 pwm configuration and control functions //---------------------------------------------------------------------------------------------------// // VRS51L2070-pwm_cfg_function_sdcc.c // //--------------------------------------------------------------------------------------------------// // // description: pwm configuration and control functions // //-------------------------------------------------------------------------------------------------// #include <VRS51L2070_sdcc.h> // --- functions prototypes void pwmconfig(char channel,int endval,int midval); void pwmdata8bit(char,char); void pwmdata16bit(char,int); void delay(unsigned int); void delay(unsigned int); void main (void) { int cptr = 0x00; // periphen2 = 0x02; //enable pwm sfr //clear all pwm channels pwmcfg = 0x20; // configure the pwm prescaler pwmclkcfg = 0x00; // apply a clock prescaler (div / 1) on all pwm // configure pwm polarity pwmldpol = 0x00; //set all pwm in normal polarity //pwm output = 0 until //--configure pwm5 as 8bit resolution, end = 0xff, pwm mid = 0x000 pwmconfig(0x05, 0x0ff,0x000); //--configure pwm0 as 8bit reso lution, end = 0xfff, pwm mid = 0x0000 pwmconfig(0x02, 0xfff,0x000); //continuously vary the pwm2 and pwm5 values do{ for(cptr = 0xff0; cptr > 0x00; cptr--) { pwmdata16bit(0x02,cptr); pwmdata8bit(0x05,cptr>>4); delay(1); } }while(1);
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 65 of 99 }// end of main //------------------------------------------------------------------------ // --------- individual functions ------------------------- //------------------------------------------------------------------------ //--------------------------------------------------------------------------------------// // -- pwmconfig // // -------------------------------------------------------------------------------------// // description: configure pwm channel // //--------------------------------------------------------------------------------------// void pwmconfig(char channel,int endval,int midval) { char pwmch; char pwmready = 0x00; channel &= 0x07; //make sure pwm ch number <= 7 //wait last configuration to be loaded do{ pwmready = pwmldpol; }while(pwmready != 0x00); //define pwm enable section periphen2 |= 0x02; //enable pwm sfr //--define the value to put into the pwmen register switch(channel) { case 0x00 : pwmch = 0x01; break; case 0x01 : pwmch = 0x02; break; case 0x02 : pwmch = 0x04; break; case 0x03 : pwmch = 0x08; break; case 0x04 : pwmch = 0x10; break; case 0x05 : pwmch = 0x20; break; case 0x06 : pwmch = 0x40; break; case 0x07 : pwmch = 0x80; break; }//end of switch pwmen |= pwmch; //enable the selected channel //configure pwm end point pwmcfg = (channel + 0x58); //set pwm configuration register to point to //the msb of end value and set the pwmwait bit //to prevent the pwm configuration to be loaded //before the configure sequence is completed pwmdata = endval >> 8; pwmcfg &= 0xef; //set pwm configuration register to point to //the lsb of end value pwmdata = endval; //configure pwm mid point pwmcfg = (channel + 0x50); //set pwm configuration register to point to //the msb of mid value and set the pwmwait bit //to prevent the pwm configuration to be loaded //before the configure sequence is completed pwmdata = midval >> 8; pwmcfg &= 0xef; //set pwm configuration register to point to //the lsb of end value pwmdata = midval; pwmcfg &= 0x3f; //allows pwm update upon end of next pwm cycle }//end of pwmdata16bit() //--------------------------------------------------------------------------------------// // -- pwmdata8bit // // -------------------------------------------------------------------------------------// // description: allow pwm channel data update // // ( 8bit data )l // //--------------------------------------------------------------------------------------// void pwmdata8bit(char channel,char pwmdata) { channel &= 0x07; //make sure pwm ch number <= 7 //--check that te last configuration has been loaded pwmcfg = (channel + 0x40); //write new value in pwm config //prevent pwm configuration to be loaded //before the configure sequence is completed pwmdata = pwmdata; //write new data into the pwm registers pwmcfg &= 0x3f; //allows pwm update upon end of next pwm cycle }//end of pwmdata8bit() //--------------------------------------------------------------------------------------// // -- pwmdata16bit // // -------------------------------------------------------------------------------------// // description: allow pwm channel data update // // ( 16bit data )l // //--------------------------------------------------------------------------------------// void pwmdata16bit(char channel,int pwmdata) { channel &= 0x07; //make sure pwm ch number <= 7 pwmcfg = (channel + 0x50); //set pwm configuration register to point to //the msb of data value and set the pwmwait bit //and set the pwmwait bit to prevent the //pwm configuration to be loaded //before the configure sequence is completed pwmdata = pwmdata >>8; pwmcfg &= 0xef; //set pwm configuration register to point to //the lsb of data value pwmdata = pwmdata; pwmcfg &= 0x3f; //allows pwm update upon end of next pwm cycle }//end of pwmdata16bit() //;--------------------------------------------------------------------------------// //;- delay1msto : 1ms delay using timer0 // //; // //; calibrated for 40mhz // //;--------------------------------------------------------------------------------// void delay(unsigned int dlais){ idata unsigned char x=0; idata unsigned int dlaisloop; x = periphen1; //load periphen1 reg x |= 0x01; //enable timer 0 periphen1 = x; dlaisloop = dlais; while ( dlaisloop > 0) { th0 = 0x63; //timer0 reload value for 1ms at 40mhz tl0 = 0xc0; t0t1clkcfg = 0x00; //no prescaler for timer 0 clock t0con = 0x04; //start timer 0, count up do{ x=t0con; x= x & 0x80; }while(x==0); t0con = 0x00; //stop timer 0 dlaisloop = dlaisloop-1; }//end of while dlais... x = periphen1; //load periphen1 reg x = x & 0xfe; //disableble timer 0 periphen1 = x; }//end of function delais
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 66 of 99 11.5 using pwm modules as timers by appropriately configuring the pwmtmren sfr, the pwm modules can also operate as general purpose 16-bit timers. the following table describes the pwmtmren register: t able 118: pwm t imer m ode e nable register - pwmtmren sfr ad h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 pwm7tmren pwm 7 module operating mode 0 = pwm 7 module is configured as pwm 1 = pwm 7 module is configured as timer 6 pwm6tmren pwm 6 module operating mode 0 = pwm 6 module is configured as pwm 1 = pwm 6 module is configured as timer 5 pwm5tmren pwm 5 module operating mode 0 = pwm 5 module is configured as pwm 1 = pwm 5 module is configured as timer 4 pwm4tmren pwm 4 module operating mode 0 = pwm 4 module is configured as pwm 1 = pwm 4 module is configured as timer 3 pwm3tmren pwm 3 module operating mode 0 = pwm 3 module is configured as pwm 1 = pwm 3 module is configured as timer 2 pwm2tmren pwm 2 module operating mode 0 = pwm 2 module is configured as pwm 1 = pwm 2 module is configured as timer 1 pwm1tmren pwm 1 module operating mode 0 = pwm 1 module is configured as pwm 1 = pwm 1 module is configured as timer 0 pwm0tmren pwm 0 module operating mode 0 = pwm 0 module is configured as pwm 1 = pwm 0 module is configured as timer when operating in timer mode, the pwm module timer will count from 0000h up to the maximum pwm timer value defined by the pwm mid sub registers, which are accessible through the pwmcfg register. t able 119: s ummary of pwm mid sub registers access pwmcfg bit pwmlsbmsb pwmcfg bit pwmmidend pwm timer msb max count value 0 1 pwm timer msb max count value 1 1 once the pwm mid value is reached, the pwm timer overflow is set and the pwm timer rolls over to 0000h. the pwm timer flags are raised when the timer reaches the maximum value set by pwmmidh and pwmmidl, and then it is reset and starts again. t able 120: pwm t imer f lags register - pwmtmrf sfr ae h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 pwm7tmrf pwm 7 module timer flag 0 = no overflow 1 = pwm timer 7 overflow 6 pwm6tmrf pwm 6 module timer flag 0 = no overflow 1 = pwm timer 6 overflow 5 pwm5tmrf pwm 5 module timer flag 0 = no overflow 1 = pwm timer 5 overflow 4 pwm4tmrf pwm 4 module timer flag 0 = no overflow 1 = pwm timer 4 overflow 3 pwm3tmrf pwm 3 module timer flag 0 = no overflow 1 = pwm timer 3 overflow 2 pwm2tmrf pwm 2 module timer flag 0 = no overflow 1 = pwm timer 2 overflow 1 pwm1tmrf pwm 1 module timer flag 0 = no overflow 1 = pwm timer 1 overflow 0 pwm0tmrf pwm 0 module timer flag 0 = no overflow 1 = pwm timer 0 overflow f igure 29: pwm as t imers overview pwmtmrpr(7:4) div ratio: sys clk / 1 downto sys clk / 16384 sys clk pwmtmrpr(3:0) div ratio: sys clk / 1 downto sys clk / 16384 pwm7 module pwm6 module pwm5 module pwm4 module pwm7 pin pwm6 pin pwm5 pin pwm4 pin pwm3 module pwm2 module pwm1 module pwm0 module pwm3 pin pwm2 pin pwm1 pin pwm0 pin pwm6en pwm5en pwm7en pwm4en pwm2en pwm1en pwm3en pwm0en pwmen periphen2
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 67 of 99 11.6 configuring the pwm timers configuring the pwm modules to operate in pwm timer mode requires the following steps: 1. activate the pwmsfr register 2. configure the pwm clock prescaler (if required) 3. set the pwmldpol register to 00h 4. configure the pwm timer maximum count value by setting the pwm mid sub-registers 5. configure the pwm timer interrupts (if required) 6. configure the pwm modules as timers 7. enable the pwm modules follow the code example below to perform these seven steps : (?) periphen2 |= 0x02; //enable pwm sfr //--configure the pwm prescaler pwmclkcfg = 0x03; //apply a clock prescaler (div / 8) on pwm 3:0 //--configure pwm polarity pwmldpol = 0x00; //set all pwm in normal polarity //pwm output = 0 until //--configure pwm5 as timer // pwm timer 5 counts from 0000 to f000h pwmcfg = 0x15; //point to msb mid pwmdata = 0xf0; //set pwm as timer max msb pwmcfg = 0x05; //point to lsb mid pwmdata = 0x00; //set pwm as timer max lsb //--configure and enable pwm as timer interrupt to monitor pwm5 only intsrc2 &= 0xdf; //pwm7:4 timer module interrupt intpinsens1 = 0xdf; // sensitive on high level(0) intpininv1 = 0xdf; //set int0 pin sensitivity on normal level(0) inten2 |= 0x20; //enable pwm7:4 timer module interrupt //--activate the pwm module and cofigure the pwm modules 5 as timer pwmen |= 0x20; //enable pwm 5 pwmtmren |= 0x20; //enable pwm 5 as timer geninten = 0x03; //enable global interrupt 11.7 pwms as timers example programs 11.7.1 configuring pwm0 and pwm5 as timers the following example program demonstrates how to initialize pwm0 and pwm5 as general purpose timers, and how to monitor the pwm timer?s overflow flags by pooling or via an interrupt. //--------------------------------------------------------------------------------------------------------------// // VRS51L2070-pwm_as_timer1_sdcc.c.c // //-------------------------------------------------------------------------------------------------------------// // // description: pwm as timer example program // enable and configure pwm timer 0 // apply a clock prescaler on pwm timer 0 (div/8) // enable and configure pwm timer 5 // monitor pwm timer 0 ov flag by pooling // when pwm timer 0 overflow, toggle p1.0 pin // monitor pwm timer 5 ov flag by interrupt // when pwm timer 5 overflow interrupt occurs toggle p1.5 pin ///-------------------------------------------------------------------------------------------------------------// #include <VRS51L2070_sdcc.h> void main (void) { int cptr = 0x00; char flagread; periphen2 |= 0x02; //enable pwm sfr //configure port1 as output p1pincfg = 0x00; //clear all pwm channels // pwmcfg = 0x20; // configure the pwm prescaler pwmclkcfg = 0x03; // apply a clock prescaler (div / 8) on pwm 3:0 // configure pwm polarity pwmldpol = 0x00; //set all pwm in normal polarity //pwm output = 0 until //--configure pwm0 as timer (will be monitored by pooling) // pwm timer 0 counts from 0000 to 01f0h pwmcfg = 0x10; //point to msb mid pwmdata = 0x01; pwmcfg = 0x00; //point to lsb mid pwmdata = 0xf0; //--activate the pwm modules and configure the pwm modules as timers pwmen |= 0x01; pwmtmren |= 0x01; //enable pwm 0 as timer //--configure pwm5 as timer (will be monitored by interrupt) // pwm timer 5 counts from 0000 to f000h pwmcfg = 0x15; //point to msb mid pwmdata = 0xf0; // pwmcfg = 0x05; //point to lsb mid pwmdata = 0x00; //--configure and enable pwm as timer interrupt to monitor pwm5 only intsrc2 &= 0xdf; //pwm7:4 timer module interrupt intpinsens1 = 0xdf; // sensitive on high level(0) intpininv1 = 0xdf; //set int0 pin sensitivity on normal level(0) inten2 |= 0x20; //enable pwm7:4 timer module interrupt //--activate the pwm modules and configure the pwm modules as timers pwmen |= 0x20; //enable pwm 5 pwmtmren |= 0x20; //enable pwm 5 as timer geninten = 0x03; //enable global interrupt while(1){ //wait for pwm0 as timer overflow flag pwm0 timer flag pooled do { flagread = pwmtmrf; flagread &=0x01; }while(flagread == 0); pwmtmrf &= 0xfe; //clear the pwm0 timer flag p1 = p1^0x01; //toggle p1.0 }//end of while(1) }// end of main //------------------------------------------------------ // //----- interrupt int13 - pwm7:4 as timer // //------------------------------------------------------// void int13interrupt(void) interrupt 13 { char flagread; inten2 = 0x00; //disable pwm7:4 timer module interrupt flagread = pwmtmrf; //read pwm timer ov flags flagread &= 0x20; //check if pwm timer 5 ov flag is active if(flagread != 0x00) p1 = p1^0x20; //toggle p1.5 pwmtmrf &= 0xdf; //clear the pwm timer 5 ov flag inten2 |= 0x20; //enable pwm7:4 timer module interrupt }//end of int0 interrupt
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 68 of 99 12 enhanced arithmetic unit the VRS51L2070 includes a hardware-based, enhanced arithmetic unit, which enables fast arithmetic operations. this arithmetic unit is similar to the mult/accu unit on the versa mix 8051, with the added ability to support 16-bit division. 12.1 VRS51L2070 arithmetic unit features the main features of the arithmetic unit are: o hardware calculation engine o calculation result is ready as soon as the input registers are loaded o signed mathematical calculations o unsigned math operations are possible if the mul engine operands are limited to 15 bits in length o auto/manual reload of au result register o easy implementation of complex mathematical operations o 16-bit and 32-bit overflow flag o 32-bit overflow can set an interrupt o arithmetic unit operand registers can be cleared individually or simultaneously o overflow flags can be configured to stay active until manually cleared o can store and use results from previous operations the arithmetic unit can be configured to perform the following operations: f igure 30: VRS51L2070 a rithmetic u nit operations add32 + add32 mult16 + add32 (aua, aub) + auc = aures div16 (aua x auprev(16lsb) + auc = aures (aua x auprev(16lsb) + 0 = aures (aua x auprev(16lsb) + auprev = aures (aua x aua) + 0 (aua x aua) + auc = aures = aures (aua x aua) + auprev = aures (aua x aub) + 0 (aua x aub) + auc = aures = aures (aua x aub) + auprev = aures (aua / aub) = aures where aua (multiplier), aub (multiplicand), auc (accumulator), aures (res ult) and auprev (previous result) are 16, 16, 32, 32 and 32-bits wide, respectively. 12.2 arithmetic unit control registers with the exception of the bar rel shifter, the arithmetic unit?s operation is controlled by two sfr registers: o auconfig1 o auconfig2 the following tables describe these control registers: t able 121: a rithmetic c onfig r egister 1 ? auconfig1 sfr c2 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description read: always read as 0 7 capprev capture previous result enable 0 = previous result capture is disabled 1 = capture the previous result if capmode bit is set to 1 6 capmode 0 = the capture of previous result is automatic each time a write operation is done to the au0 1 = the capture of the previous result is manual and occurs when the capprev bit is set to 1 5 ovcapen capture result on 32-bit overflow 0 = no result capture is performed 1 = the au result is captured and stored when a 32-bit overflow condition occurs 4 readcap read stored result 0 = aures contains current operation result 1 = aures contains previous result 3:2 addsrc[1:0] au adder input n 32-bit addition source b input 00 = 0 (no add) 01 = c (std 32-bit reg) 10 = auprev 11 = auc (std 32-bit reg) a input 00=multiplication 01=multiplication 10=multiplication 11= concatenation of {a, b} + c for 32-bit addition 1:0 mulcmd[1:0] au multiplication command 00 = aua x aub 01 = aua x aua 10 = aua x auprev (16 lsb) 11 = aua x aub notes in divider mode multa_in = mult_in = 0x0000 in multiplier mode diva_in = 0x0000 and divb_in = 0x0001
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 69 of 99 t able 122: a rithmetic c onfig r egister 2 ? auconfig2 sfr c3 h 7 6 5 4 3 2 1 0 w w w r/w r r r r 0 0 0 0 0 0 0 0 bit mnemonic description read: always read as 0 7:5 auregclr [2:0] arithmetic unit operand registers clear 000 = no clear 001 = clear aua 010 = clear aub 011 = clear auc 100 = clear auprev 101 = clear all au module registers and overflow flags 110 = clear overflow flags only 4 auinten arithmetic unit interrupt enable 0 = arithmetic unit interrupt is disabled 1 =-arithmetic unit interrupt is enabled in divider mode 3 - not used, read as 0 2 divoutrg au division is out of range flag this flag is set if aub = 0x0000 or (aua = 0x8000 and aub = 0xffff) 1 auov16 arithmetic unit 16-bit overflow flag 0 = no 16 bit overflow condition detected 1 = a 16-bit overflow occurred will occur if there is a carry on from bit 15 to bit 1,6 but also from bit 31 to bit 32 0 auov32 arithmetic unit 32-bit overflow flag 0 = no 16 bit overflow condition detected 1 = operation result is larger than 32 bits 12.3 arithmetic unit data registers the arithmetic unit data registers include operand and result registers that serve to store the numbers being manipulated in mathematical operations. some of these registers are uniquely for addition (such as auc), while others can be used for all operations. the use of the arithmetic uni t operation registers is described in the following sections. 12.4 aua and aub multiplication (addition) input registers the aua and aub registers serve as 16-bit input operands when performing multiplication. when the arithmetic unit is configured to perform 32-bit addition, the aua and the aub registers are concatenated. in this case, the aua register contains the upper 16 bits of the 32-bit operand and the aub contains the lower 16 bits. t able 123: a rithmetic u nit a register bit [7:0] - aua0 sfr a2 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 aua[7:0] lsb of the a operand register t able 124: a rithmetic u nit a register bit [15:8]- aua1 sfr a3 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 aua[15:8] msb of the a operand register t able 125:a rithmetic u nit b register bit [7:0] - aub0 sfr b2 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 aub[7:0] lsb of the b operand register for multiplication and addition operations t able 126:a rithmetic u nit d ivision m ode r egister ? aub0div sfr b1 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 aub0div[7:0] writing to this byte instead of aub0 will set the arithmetic unit to divisor mode t able 127: a rithmetic u nit b register bit [15:8] - aub1 sfr b3 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 aub[15:8] msb of the b operand register
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 70 of 99 12.5 auc input register the auc register is a 32-bit register used to perform 32-bit addition. the auprev register can be substituted with the auc regi ster or by 0 in the 32-bit addition. t able 128:a rithmetic u nit c register bit [7:0] - auc0 sfr a4 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 auc[7:0] bit [7:0]of the c operand register t able 129: a rithmetic u nit c register bit [15:8] - auc1 sfr a5 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 auc[15:8] bit [15:8] of the c operand register t able 130:a rithmetic u nit c register bit [23:16] - auc2 sfr a6 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 auc[23:16] bit [23:16] of the c operand register t able 131:a rithmetic u nit c register bit [31:24] ? auc3 sfr a7 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 auc[31:24] bit [31:24] of the c operand register 12.6 the arithmetic unit aures register the aures register, which is 32 bits wide, is read-only and contains the result of the last arithmetic unit operation. the aures register is located at the output of the barrel shifter. when the arithmetic unit is configured to perform multiplication and/or addition, the aures operates as a 32-bit register that contains the result of the previous operation(s). however when the arithmetic unit has performed a 16- bit division, the upper 16 bits of the aures register contain the quotient of t he operation, while the lower 16 bits contain the remainder of the division operation. the barrel shifter is deactiv ated when the arithmetic unit is performing 16-bit division. four sfr registers located in sfr page 1 provide access to the arithmetic unit aures register. t able 132: a rithmetic u nit result register bit [7:0] - aures0 sfr b4 h 7 6 5 4 3 2 1 0 r r r r r r r r 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 aures[7:0] bit [7:0]of the result register t able 133: a rithmetic u nit r esult register bit [15:8] - aures1 sfr 5 h 7 6 5 4 3 2 1 0 r r r r r r r r 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 aures[15:8] bit [15:8] of the result register t able 134: a rithmetic u nit result register bit [23:16] ? aures2 sfr b6 h 7 6 5 4 3 2 1 0 r r r r r r r r 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 aures[23:16] bit [23:16] of the result register t able 135: a rithmetic u nit result register bit [31:24] ? aures3 sfr b7 h 7 6 5 4 3 2 1 0 r r r r r r r r 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 aures[31:24] bit [31:24] of the result register
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 71 of 99 12.7 auprev register the auprev register can automatically or manually save the contents of the aures register and re-inject it into the calculation. this feature is especially useful in applications where the result of a given operation serves as one of the operands for the next one. as previously mentioned, there are two ways to load the auprev register. this is controlled by the capmode bit value as follows: capmode = 0: auto auprev load, by writing into the aua0 register. selected when capprev = 0. capmode = 1: manual load of auprev when the capprev bit is set to 1. auto loading of the auprev register is useful in fir filter calculations. for exampl e, it is possible to save a total of eight mov operations per tap calculation. t able 136: a rithmetic u nit p revious r esult bit [7:0] - auprev0 sfr c4 h 7 6 5 4 3 2 1 0 r r r r r r r r 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 auprev[7:0] bit [7:0]of the previous result register t able 137:a rithmetic u nit p revious r esult bit [15:8] - auprev1 sfr c5 h 7 6 5 4 3 2 1 0 r r r r r r r r 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 auprev[15:8] bit [15:8] of the previous result register t able 138:a rithmetic u nit p revious r esult bit [23:16] ? auprev2 sfr c6 h 7 6 5 4 3 2 1 0 r r r r r r r r 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 auprev[23:16] bit [23:16] of the previous result register t able 139:a rithmetic u nit p revious r esult bit [31:24] ? auprev3 sfr c7 h 7 6 5 4 3 2 1 0 r r r r r r r r 0 0 0 0 0 0 0 0 bit mnemonic description 7:0 auprev[31:24] bit [31:24] of the previous result register 12.8 multiplication and accumulate operations the multiplication and accumulate operations of the arithmetic unit are defined by the mulcmd[1:0] and addsrc[1:0] bits of the auconfig1 register. t able 140: m ultiplication operations vs . mulcmd bit of the auconfig1 mulcmd[1:0] multip lication operation 00 aua x aub 01 aua x aua 10 aua x auprev (16lsb) 11 aua x aua t able 141: a ddition operations vs . addsrc bit of the auconfig1 addsrc[1:0] addition operation 00 no addition 01 auc 10 auprev[31:0] 11 32-bit addition of [aua,aub] + auc the following figure provides a block diagram representation of the arithmetic unit operation for multiplication and addition. f igure 31: a rithmetic u nit m ultiplication and a ddition overview x + ms b lsb multiplicand 2 aub(1:0) aua(1:0) auprev(3:0) aub(1:0) mulcmd{1:0} aua1 aua0 ms b lsb multiplicand 1 00 01 10 11 aub1 aub0 lsb aua1 aua0 ms b adder1 = 0 auc(3:0) auprev(3:0) 32 bit add {aua,aub} + auc addsrc{1:0} 00 01 10 11 ms b lsb adder ms b lsb barrel shifter aures(3:0) aushiftcfg =11 addsrc{1:0} 10 01 00 the following table provides examples of the auconfig and aushiftcfg register values and the corresponding math operations performed by the arithmetic unit. it also provides the value that would be present in the aures register if the arithmetic unit input registers were initialized to the following values: ? aua = 3322h ? aub = 4411h ? auc = 11111111h ? auprev = 12345678h
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 72 of 99 t able 142:c onfiguration of the a rithmetic u nit , operation and o utput result auconfig1 auconfig1 operation aures 00h 01h aua x au! 0a369084h 00h 00h aua x aub 0d986d42h 00h 03h aua x aub 0d986d42h 00h 02h aua x auprev15:0 114563f0h 00h 0ch, 0dh,0eh,0fh (aua,aub) + auc ] 32 bit addition 44335522h 00h 04h (aua x aub)+ auc 1ea97e53h 01h 04h ((aua x aub)+ auc) x 2 (shift 2 left) 3d52fca6h 3fh 04h ((aua x aub)+ auc) / 2 (shift 2 right) f54bf29h multiplication and accumulate operations take place within one system clock cycle. 12.9 division operation (aua / aub1:aub0div) the VRS51L2070 arithmetic unit can be configured to perform 16-bit division operations: the division of aua by aub1,aub0div. the quotient of this operation is stored in the aures3, aures2 registers, with the remainder stored in the aures1, aures0 registers the following figure represents a 16-bit division. f igure 32: a rithmetic u nit d ivision overview aua1 aub0div msb lsb aures3 aures2 msb lsb quotient remainder aures1 aures0 msb lsb aua1 aua0 msb lsb dividend divisor division operation is triggered by writing lsb of divisor into the aub0div register writing the lsb of the divisor into the aub0div register will trigger a divi sion operation. once the division starts, the value written in the aub0div register will be automatically transferred into the aub0 register. this operation is neither affected by the barrel shifter nor the multiplication/addition operation, defined by the auconfig register. the division operation takes five system clock cycles to be complete. 12.10 barrel shifter the arithmetic unit includes a 32-bit barrel shifter at the output of the 32-bit addition unit. the barrel shifter is used to perform right/left shift operations on the arithmetic unit output. the shift operation takes only one cycle. the barrel shifter can be used to scale the output result of the arithmetic unit. the shifting range is adjustable from 0 to 16 in both directions. the ?shifted? value can be routed to: o aures o auprev o auov32 moreover, the shift left operation can be configured as an arithmetic or logical shift, in which the sign bit is discarded. t able 143: a rithmetic u nit s hift r egister config - aushiftcfg sfr c1 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 shiftmode au barrel shifter shift mode 0 = shift value is unsigned 1 = shift value is signed 6 arithshift au arithmetic shift enable 0 = left shift is considered as logical shift (sign bit is lost) 1 = left shift is arithmetic shift where sign bit is kept 5:0 shift[5:0] the value of shift[5:0] equals the amplitude of the shift performed on the arithmetic unit result register aures positive value represent shift to the left negative value represent shift to the right the barrel shifter sectio n operates independently of the multiply and accumulate sections on the arithmetic unit. as such, if the aushiftcfg register bits 5:0 are set to a value other than 0, the value of auprev, if derived from the aures regist er either automatically or manually, will be affected by the barrel shifter. when the arithmetic unit is configured to perform multiplication and addition operations, the barrel shifter is active and the shift operation performed depends on the current value of the aushiftcfg register. when the arithmetic unit is configured to perform 16-bit division, the barrel shifter is deactivated.
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 73 of 99 12.11 VRS51L2070 arithmetic unit block diagram the following block diagram provides a hardware description of the registers and the othe r components that comprise the arithmetic unit on the VRS51L2070. f igure 33: a rithmetic u nit f unctional d iagram aua1 (msb) aua0 (lsb) aub1 (msb) aub0 (lsb) sfr registers auc3 (msb) auc2 auc1 auc0 (lsb) aua aub mul (signed) mulcmd add msb add lsb addsrc auc auov3 2 shift rdstored aures auprev aua0 load capprev manloop aures (sfr regs) load shiftmode ov16 a 0 (16 lsb) aures2 aures3 (msb) aures1 aures0 (lsb) sfr registers sfr registers auprev3 (msb) auprev2 auprev1 auprev0 (lsb) auconfig2 aushiftcfg auconfig1 arithmetic unit control sfr addsrc b b a a concatenation (a,b) auov1 6 stored result ovcapen auov3 2 aub0div (lsb) *for division operations only previous multiplication / addition 16 bit division aua aub aua div by aub (signed) divoutrg aures(1:0) aures(3:2) quotient remainder
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 74 of 99 12.12 arithmetic unit example programs 12.12.1 basic arithmetic operations using the arithmetic unit the following example program demonstrates the required arithmetic unit configuration to perform mathematical operations //----------------------------------------------------------------------------------------------/ // VRS51L2070_multaccu1_sdcc.c // //----------------------------------------------------------------------------------------------/ // // description: VRS51L2070 arithmetic unit demonstration program // //----------------------------------------------------------------------------------------------/ #include <VRS51L2070_sdcc.h> //-------------------------------------------------------------/ // main function //-------------------------------------------------------------/ void main (void) { periphen2 = 0x20; //enable arithmetic unit devmemcfg = 0x01; //select sfr page 1 //configure arithmetic unit to perform math operations //place value in aua aua1 = 0x33; aua0 = 0x22; //place value in aub aub1 = 0x44; aub0 = 0x11; //place value in auc auc3 = 0x11; auc2 = 0x11; auc1 = 0x11; auc0 = 0x11; //place value in auprev auprev3 = 0x12; auprev2 = 0x34; auprev1 = 0x56; auprev0 = 0x78; //--some operation examples-- // to perform: [(auaxaua)+0] auconfig1 = 0x01; //set operation (aua x aua) + 0 //aures = 0a369084h // to perform: [(auaxaub)+0] auconfig1 = 0x00; //set operation (aua x aub) + 0 //aures = 0d986d42h // or auconfig1 = 0x03; //set operation (aua x aub) + 0 //aures = 0d986d42h // to perform: [(aua x auprev[15:0]))+0] auconfig1 = 0x02; //set operation (auaxauprev)+0 //aures = 114563f0h // to perform: [ (aua,aub) + auc ] 32 bit addition auconfig1 = 0x0c; //set operation (aua,aub)+ auc //aures = 44335522h //or... auconfig1 = 0x0d; //set operation (aua,aub)+ auc //aures = 44335522h //or... auconfig1 = 0x0e; //set operation (aua,aub)+ auc //aures = 44335522h //or... auconfig1 = 0x0f; //set operation (aua,aub)+ auc //aures = 44335522h // to perform: [ (aua x aub)+ auc ] no shift auconfig1 = 0x04; //set operation (aua x aub)+ auc aushiftcfg = 0x00; //no shift //aures = 1ea97e53h // to perform: [ (aua x aub)+ auc ] x 2 (shift one left) auconfig1 = 0x04; //set operation (aua x aub)+ auc aushiftcfg = 0x01; //set barrel shifter to perform one shift left (logical) //no need to preset the aushiftcfg register for every //operations //aures = 3d52fca6h // to perform: [ (aua x aub)+ auc ] / 2 (shift one right) auconfig1 = 0x04; //set operation (aua x aub)+ auc aushiftcfg = 0x3f; //set barrel shifter to perform one shift right //no need to preset the aushiftcfg register for every //operations //aures = f54bf29h devmemcfg = 0x00; //select sfr page 0 while(1); }// end of main 12.12.2 fir filter function the following example program shows the implementation 2070of a fir filter computation function for one iteration; a data shifting operation; and the definition of the fir filter coefficient table. the fir computation algorithm is simple to implement, but requires a lot of processing power. for each new data point, multiplication with the associated coefficients and addition operations must be performed n times (n=number of filter taps). since it is hardware-based, the VRS51L2070 arithmetic unit is very effici ent in performing operations such as fir filter computation. in the example below, the computefir loop is the ?heart? of the fir computation. note that bec ause of the arithmetic unit?s features, very few instructions are needed to perform mathematical operations and the calculation results are ready at the next instruction. this provides a dramatic performance improvement when compared to having to perform all math operations manually, using general processor instructions. //-----------------------------------------------------------// // VRS51L2070_au_fir_asm_c_-sdcc.c // //-----------------------------------------------------------------------------------------------------------------------// // // description: fir filter demonstration program - mixed asm and c coding to optimize // the fir loop speed. // // this program demonstrates the configuration and use of the spi interface // for interface to serial 12-bit a/d and d/a converters. // the program reads the a/d and outputs the read value on a d/a converter // // at 40mhzm the 16-tap fir loop + data shifting of the VRS51L2070 provide the // following performances: // // fir computation using au module (asm) = 10.4 useconds // data shifting (asm) = 17.2 useconds // fir computation + datashift = 27.6 useconds (1/t = 36.2 khz) // // rev 1.0 // date: august 2005 //-------------------------------------------------------------------------------------------------------------------// #include <VRS51L2070_sdcc.h> //--fir filter coefficient tables //;fsample 480hz, n=16, low pass 0.1hz -78db @ 60hz const int flashfircoef[] = {0x023d,0x049d,0x086a,0x0d2d,0x1263,0x1752,0x1b30,0x1d51, 0x1d51,0x1b30,0x1752,0x1263,0x0d2d,0x086a,0x049d,0x023d};
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 75 of 99 //-- global variables definition int at 0x30 fircoef[16]; int at 0x50 datastack[16]; unsiged int at 0x75 dacdata; //---- functions declaration ----// //-- fir filter computation function void fircompute(void); void copyfircoef(void); //--gen_adc void readgen_adc(void); // //- gen_dac void writegen_dac(unsigned int ); //---generic functions prototype void v2kdelay1ms(unsigned int); //standard delay function // global variables definitions idata unsigned char cptr = 0x00; unsigned int adcdata = 0x00; //-----------------------------------------------------------// //--------- main function -----------------// //-----------------------------------------------------------// void main (void) { periphen2 |= 0x02; //enable pwm sfr p2pincfg = 0xf0; //p2[3:0] is output pwmclkcfg = 0x10; //pwm timer 7 prescaler = sys clock / 2 //--configure pwm7 as timer (will be monitored by interrupt) // pwm timer 7 counts from 0000 to a2c2h pwmcfg = 0x17; //point to msb mid pwmdata = 0xa2 pwmcfg = 0x07; //point to lsb mid pwmdata = 0xc2; //--configure and enable pwm as timer interrupt to monitor pwm5 only intsrc2 &= 0xdf; //pwm7:4 timer module interrupt intpinsens1 = 0xdf; // sensitive on high level(0) intpininv1 = 0xdf; //set int0 pin sensitivity on normal level(0) inten2 |= 0x20; //enable pwm7:4 timer module interrupt //-- copy fir filter coefficients to iram copyfircoef(); //--activate the pwm modules and configure the pwm modules as timers pwmen |= 0x80; //enable pwm 7 pwmtmren |= 0x80; //enable pwm 7 as timer geninten = 0x01; //enable global interrupt while(1); }// end of main //-----------------------------------------------------------------------------// //---------------------- interrupt function----- ----------------------// //-----------------------------------------------------------------------------// //------------------------------------------------------------------------------- // name: int13interrupt pwmtmr7:4 as timer //------------------------------------------------------------------------------- void int13interrupt(void) interrupt 13 { char flagread; inten2 = 0x00; //disable pwm7:4 timer module interrupt flagread = pwmtmrf; //read pwm timer ov flags flagread &= 0x80; //check if pwm timer 7 ov flag is active if(flagread != 0x00) { p2 = p2^0x01; //toggle p2.0 (test) readgen_adc(); //read the a/d converter fircompute(); //perform the fir filter computation and write into dac } pwmtmrf &= 0x7f; //clear the pwm timer 7 ov flag inten2 |= 0x20; //enable pwm7:4 timer module interrupt }//end of pwm as timer interrupt //-----------------------------------------------------------------------------// //---------------------- indi vidual functions ---------------------------// //-----------------------------------------------------------------------------// //------------------------------------------------------------------------ // name: fircompute //----------------------------------------------------------------------- void fircompute() { char *coef = &fircoef; char *ydata = &datastack; char fircptr = 0x00; periphen2 |= 0x20; //enable the arithmetic unit p2 = 0xff; //set p2 = 0xff to monitor duration for fir loop *ydata = adcdata & 0x0ff; //store the lsb of adc read data ydata += 1; *ydata = (adcdata >> 8)&0x00ff; //store the msb of adc read data devmemcfg = 0x01; //switch to sfr page 1 auconfig1 = 0x08; //caprev = 0 : previous res capture is automatic //capmode = 1 : capture of previous result //occurs when aua0 is written into //ovcapen = 0 : capture on ov32 disabled //readcap = 0 : aures contains current result //addsrc = 10 : add scr = auc //mulcmd = 00 : mul cmd = aua x aub auconfig2 = 0xa0; //clear the arithmetic unit registers _asm mov r0,#0x30; //copy start address of fir coefficient table into r0 mov r1,#0x50; //copy start address of fir data table into r1 _endasm; // yn computation mostly in assembler -- faster... for(fircptr = 0; fircptr < 16; fircptr++) { _asm mov 0xa2,@r0; //copy lsb of pointed coefficient to aua0 inc r0; mov 0xa3,@r0; //copy msb of pointed coefficient to aua1 inc r0; mov 0xb2,@r1; //copy lsb of pointed coefficient to aub0 inc r1; mov 0xb3,@r1; //copy msb of pointed coefficient to aub1 inc r1; _endasm; }//end of for cptr //-- performing the data stack shifting allows to save 8.8us @ 40mhz _asm mov r0,#0x6f; mov r1,#0x71; _endasm; for(fircptr = 16; fircptr > 0; fircptr--) { _asm mov a,@r0; mov @r1,a; dec r0; dec r1; mov a,@r0; mov @r1,a; dec r0; dec r1; _endasm; }//end of shift for loop //-scale down the aures output by 16 using the barrel shifter // the coefficient had been scaled up by a factor of 65536 aushiftcfg = 0x30; _asm nop; _endasm; p2 = 0x00; //set p2 = 0x00 to signal the end of the fir loop dacdata = (aures1 << 8) + aures0; //reset the barrel shifter aushiftcfg = 0x00; // note: // in this case, 6 system clock cycles could be saved // by reading aures3 and aures2 directly devmemcfg = 0x00; //switch to sfr page 0 writegen_dac(dacdata); //write data to spi dac }//end of fircompute //------------------------------------------------------------------------ // name: copyfircoef //----------------------------------------------------------------------- // description: copy the fir filter coefficient into // sram variable which is faster access // than flash //----------------------------------------------------------------------- void copyfircoef(void) { char cptr = 0x00;
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 76 of 99 for(cptr = 0x00; cptr < 16; cptr++) fircoef[cptr]= flashfircoef[cptr]; }//end of copyfircoef //------------------------------------------------------------------------ // name: readgen_adc //----------------------------------------------------------------------- // description: read the gen_adc a/d // adc is connected to spi interface using cs0 // max clk speed is 3.2mhz, fosc = 40mhz assumed //------------------------------------------------------------------------ void readgen_adc() { int cptr = 0x00; char readflag = 0x00; //spi configuration section /(can be moved to main function if only one device is connected to the spi interface) periphen1 |= 0xc0; //make sure the spi interface is activated //--wait activity stops on the spi interface (monitor spinocs) while(!(spistatus &= 0x08)); spictrl = 0x65; //spiclk = /16 (2.5mhz) //cs0 active //spi mode 1 phase = 1, pol = 0 //spi master mode spiconfig = 0x40; //spi chip select is automatic //clear spiundefc flag //spiload = 0 -> manual cs3 behaviour //no spi interrupt used spistatus = 0x00; //spi transactions are in msb first format spisize = 0x0e; //spi transaction size are 15-bit //-dummy read the spi rx buffer to clear the rxav flag readflag = spirxtx0; //-perform the spi read spirxtx0 = 0x00; //writing to the spirxtx0 will trigger the spi //transaction //wait for the spi rx av flag being set while(!(spistatus &= 0x02)); /* // -- it is possible to monitor the spinocs flag instead of the spirxav flag //the code piece below shows how to do it. however in that case, //no that the reading of the spistatus register must be done at //least 4 system clock cycles after the write operation to the spirxtx0 register //-wait for spinocs flag have time to be updated _asm nop; _endasm; //--wait activity stops on the spi interface while(!(spistatus &= 0x08)); */ //read spi data adcdata= (spirxtx1 << 8); adcdata+= spirxtx0; adcdata&= 0x0fff; //isolate the 12 lsb of the read value }//end of readgen_adc //------------------------------------------------------------------------------------------// // name: writegen_dac //------------------------------------------------------------------------------------------// // description: write 12bit data into the gen_dac device // adc is connected to spi interface using cs1 // max clk speed is 12.5mhz, fosc = 40mhz assumed // we will set the spi prescaler to sysclk / 8 // void writegen_dac(unsigned int dacdata) { char subdata = 0x00; char readflag = 0x00; periphen1 |= 0xc0; //make sure the spi interface is activated //--wait activity stops on the spi interface (monitor spinocs) while(!(spistatus &= 0x08)); //spi configuration section //can be moved to main function if only one device is connected to the spi interface spictrl = 0x4d; //spiclk = /8 (mhz) //cs1 active //spi mode 1 phase = 1, pol = 0 //spi master mode spiconfig = 0x40; //spi chip select is automatic //clear spiundefc flag //spiload = 0 -> manual cs3 behaviour //no spi interrupt used spistatus = 0x00; //spi transactions are in msb first format spisize = 0x0b; //spi transaction size are 12 bit //-format the 12 bit data so data bit 11 is positioned on bit 7 of spirxtx0 // and data bit 0 is positioned on bit 4 of spirxtx1 and perform the spi write operation dacdata &= 0x0fff; //make sure dacdata is <= 0fffh (12 bit) spirxtx3 = 0x00; spirxtx2 = 0x00; spirxtx1 = (dacdata << 4)& 0xf0; //-dummy read the spi rx buffer to clear th e rxav flag (facultative if spinocs is monitored) readflag = spirxtx0; spirxtx0 = (dacdata >> 4); //writing to spirxtx0 will trigger the transmission //--wait the spi transaction completes // this section can be omitted if a check of activity on the spi interface // is made before each access to it in master mode //wait for the spi rx av flag being set while(!(spistatus &= 0x02)); // -- it is possible to monitor the spin ocs flag instead of the spirxav flag //the code piece below shows how to do it. however in that case, //no that the reading of the spistatus register must be done at //least 4 system clock cycles after the write operation to the spirxtx0 register /* //-wait for spinocs flag have time to be updated _asm nop; _endasm; //--wait activity stops on the spi interface (monitor spinocs flag) while(!(spistatus &= 0x08)); */ }//end of writegen_dac //------------------------------------------------------------------------------------------// // name: v2kdelay1ms //------------------------------------------------------------------------------------------// // description: vrs2070 specific 1 millisecond delay function // using timer 0 and calibrated for 40mhz oscillator //------------------------------------------------------------------------------------------// void v2kdelay1ms(unsigned int dlais){ idata unsigned char x=0; idata unsigned int dlaisloop; periphen1 |= 0x01; //load periphen1 reg dlaisloop = dlais; while ( dlaisloop > 0) { th0 = 0x63; //timer0 reload value for 1ms at 40mhz tl0 = 0xc0; t0t1clkcfg = 0x00; //no prescaler for timer 0 clock t0con = 0x04; //start timer 0, count up do{ x=t0con; x= x & 0x80; }while(x==0); t0con = 0x00; //stop timer 0 dlaisloop = dlaisloop-1; }//end of while dlais... periphen1 &= 0xfe; //disable timer 0 }//end of function v2kdelay1ms
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 77 of 99 13 watchdog timer the VRS51L2070 includes a watchdog timer which resets the processor in case of a program malfunction. the watchdog timer is composed of a 14-bit prescaler, which derives its source from the active system clock. an overflow of the watchdog timer resets the VRS51L2070. the wdtcfg sfr register controls the watchdog timer operations. t able 144: t he w atchdog t imer register - wdtcfg 91 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:4 wdtperiod watchdog timer period configuration *see table below 3 wtimerovf wdt as timer overflow flag 0 = wdt as timer as not expired 1 = wdt as timer has overflow 2 astimer watchdog as timer 0 = wdt mode 1 = wdt operate as a regular timer (no reset) writing to this bit will clear the timer read: 0 = watchdog is counting 1 = watchdog timer period has expired 1 wdtovf write: 0 = no action 1 = clear the watchdog timer flag read: no action 0 wdtreset watchdog timer reset to reset the watchdog timer, two consecutive writes to the wdtreset bit must be made: first clear the wdtreset bit and second, set it to 1 13.1 wdt timeout period the watchdog timer timeout period is controlled by adjusting bit 7:4 of the wdtcfg register. the following table provides the approximate timeout vs. the selected wdtperiod. t able 145: t he w atchdog t imer register t imeout period wdtperiod value (4 bit) actual wdt period** approx timeout** (40mhz) 0000 0x3fff* 409 ? 600us 0001 0x3ffe 819-1000 us 0010 0x3ffd 1.23 ? 1.36 ms 0011 0x3ffb 2.05 ? 2.2 ms 0100 0x3ff4 4.92 ms 0101 0x3fe8 9.83 ms 0110 0x3fcf 20.07 ms 0111 0x3f86 49.97 ms 1000 0x3f49 74.96 ms 1001 0x3f0c 99.94 ms 1010 0x3e9e 249.86 ms 1011 0x3b3b 500.12 ms 1100 0x38d9 749.98 ms 1101 0x3677 999.83 ms 1110 0x2364 2.99 s 1111 0x0000 6.71s *not available in timer mode the watchdog timer timeout period is calculated as follows: wdt period* = 16384*(0x4000 ? wdt period) fosc *for a given configuration, the timeout period of the watchdog timer may vary by about 200us. this delay is caused by internal timing of the watchdog timer module. 13.2 resetting the watchdog timer to reset the watchdog timer, two consecutive write operations to the wdtcfg register must be performed. during the first write operation, the wdtreset bit must be clea red. during the second write operation, the wdtreset should be set to 1. this sequence is also required to set a new value for wdtperiod. for example, if the watchdog period is set to 100ms, the following sequence of operations will reset the watchdog timer: mov wdtcfg,#92h mov wdtcfg,#93h 13.3 using the watchdog as a timer the VRS51L2070 watchdog timer can also be used as a timer. in this case, the timeout period is defined by the watchdog timer period value. due to the presence of the 14-bit prescaler, long timeout periods can be achieved. configuring the watchdog timer operation as a general purpose timer is achieved by: o setting the astimer bit of the wdtcfg register to 1 o selecting the timer maximum time value of wdtperiod o performing a watchdog timer reset sequence to clear the timer and apply the timer configuration the wtimerflag bit of the wdtcfg register is used to monitor the timer overflow. when configured in timer mode, the watchdog timer does not reset the VRS51L2070 and cannot trigger an interrupt.
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 78 of 99 13.4 watchdog timer example programs initialization and reset of the watchdog timer //---------------------------------------------------------------------------------------------------------------------// // VRS51L2070-wdt_demo_sdcc.c // //---------------------------------------------------------------------------------------------------------------------// // description: VRS51L2070 watchdog timer demonstration program // *this program set p1 as output // *p1 is set to 0xff for 100ms // *initialize t he watchdog timer with a timeout period of 20ms // *clear p1 // *start a delay function // *if the delay parameter of the delay function is larger than the // timeout period of the watchdog timer, the wdt will reset the VRS51L2070 // which will bring back p1 to high level //---------------------------------------------------------------------------------------------------------------------// #include <VRS51L2070_sdcc.h> // --- function prototypes void delay(unsigned int); //-----------------------------------------------------// // main function // //-----------------------------------------------------// void main (void) { periphen1 = 0x01; //enable timer 0 periphen2 = 0x08; //enable ioport p1pincfg = 0x00; //config port 1 as output //-- enable the watchdog timer periphen2 |= 0x04; p1 = 0xff; //set p1 to output 0xff delay(100); //keep p1 high for 100ms //-- configure the watchdog timer wdtcfg = 0x62; //configure and reset the watchdog timer wdtcfg = 0x63; //bit 7:4 = wdtperiod : define the timeout period (20ms) //bit 3 = wtimerovf : wdt as timer overflow flag //bit 2 = astimer : wdt mode (0=wdt, 1=timer) //bit 1 = wdtovf : wdt overflow (timeout) flag //bit 0 = wdtreset : wdt reset. to reset wdt //this bit must be cleared, then set p1 = 0x00; //clear p1 do{ delay(10); //if delay > 20ms then the wdt will reset the VRS51L2070 //and p1 will return to high wdtcfg = 0x62; //reset the watchdog timer wdtcfg = 0x63; }while(1); //loop forever }// end of main //;------------------------------------------------------------------// //;- delay1msto : 1ms delay using timer0 //; //; calibrated for 40mhz //;-----------------------------------------------------------------// void delay(unsigned int dlais){ idata unsigned char x=0; idata unsigned int dlaisloop; x = periphen1; //load periphen1 reg x |= 0x01; //enable timer 0 periphen1 = x; dlaisloop = dlais; while ( dlaisloop > 0) { th0 = 0x63; //timer0 reload value for 1ms at 40mhz tl0 = 0xc0; t0t1clkcfg = 0x00; //no prescaler for timer 0 clock t0con = 0x04; //start timer 0, count up do{ x=t0con; x= x & 0x80; }while(x==0); t0con = 0x00; //stop timer 0 dlaisloop = dlaisloop-1; }//end of while dlais... x = periphen1; //load periphen1 reg x = x & 0xfe; //disableble timer 0 periphen1 = x; }//end of function delais 14 VRS51L2070 interrupts the VRS51L2070 has a comprehensive set of 49 interrupt sources and uses 16 interrupt vectors to handle them. the interrupts are categorized in two distinct groups: ? module interrupt ? pin change interrupts the module interrupts include interrupts that are generated by VRS51L2070 peripherals such as the uarts, spi, i2c , pwc and port change monitoring modules. as their name implies, the pin change interrupts are interrupts that are generated by predefined conditions at the physical pin level: . the pin change interrupts can be caused by a level or an edge (rising or falling) on a given pin. standard 8051 int0 and int1 interrupts are considered pi n change interrupts. the VRS51L2070 includes int0 and int1, as well as 14 other pin interrupts distributed on ports 0 and 3. the interrupt sources share 16 interrupt vectors from 00h to 7bh. each interrupt vector can be configured to respond to either a pin change interrupt or a module interrupt. the two following diagrams provide an overview of the VRS51L2070 modules/pin interrupt structure, the as sociated sfr registers and the interaction among the interrupt management sfrs. f igure 34: i nterrupt s ources detailed view 1 0 module 1 0 pin intpinfx.y bit intsrcx.y bit intpininvx.y bit intenx.y bit to interrupt controller
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 79 of 99 f igure 35: i nterrupt s ources overview 1 0 not used p3.2 - int0 pin 1 0 spi tx empty p3.3 - int1 pin 1 0 spi rx av/ov p3.0 pin 1 0 timer 0 p3.1 pin 1 0 port chg 0 p3.4 pin 1 0 uart0 p3.5 pin 1 0 uart1 p3.6 pin 1 0 timer 1 p3.7 pin 1 0 timer 2 p0.0 pin 1 0 i2c p0.1 pin 1 0 uart collision p0.2 pin 1 0 pwc modules p0.3 pin 1 0 pwm3:0 timer p0.4 pin 1 0 pwm7:4 timer p0.5 pin 1 0 wdt timer / arithmetic unit p0.6 pin 1 0 port chg 1 p0.7 pin interrupt number interrupt vector natural priority int 0 0003h 1 int 1 000bh 2 int 2 0013h 3 int 3 001bh 4 int 4 0023h 5 int 5 002bh 6 int 6 0033h 7 int 7 003bh 8 int 8 0043h 9 int 9 004bh 10 int 10 0053h 11 int 11 005bh 12 int 12 0063h 13 int 13 006bh 14 int 14 0073h 15 int 15 007bh 16 1 0 module 1 0 pin intpinfx.y bit intsrcx.y bit intpininvx.y bit intenx.y bit interrupt source config module i/o pin details of module / pin controller
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 80 of 99 the interaction between the interrupt management configurati on registers is summarized in the following table. the paragraphs below describe each one of these registers in detail. t able 146:VRS51L2070 i nterrupt c onfiguration s ummary int # priority interrupt vector interrupt enable interrupt priority interrupt source connected modules connected pin pin inversion pin sensitivity pin interrupt flag int 0 1 0003h inten1.0 intpri1.0 intsrc1.0 none p3.2-int0 ipintinv1.0 ipinsens1.0 ipinflag1.0 int 1 2 000bh inten1.1 intpri1.1 intsrc1.1 spi tx empty p3.3-int1 ipintinv1.1 ipinsens1.1 ipinflag1.1 int 2 3 0013h inten1.2 intpri1.2 intsrc1.2 spi rx available spi rx overrun p3.0 ipintinv1.2 ipinsens1.2 ipinflag1.2 int 3 4 001bh inten1.3 intpri1.3 intsrc1.3 timer 0 p3.1 ipintinv1.3 ipinsens1.3 ipinflag1.3 int 4 5 0023h inten1.4 intpri1.4 intsrc1.4 port change 0 p3.4 ipintinv1.4 ipinsens1.4 ipinflag1.4 int 5 6 002bh inten1.5 intpri1.5 intsrc1.5 uart0 tx empty uart0 rx available uart0 rx overrun uart0 timer ov p3.5 ipintinv1.5 ipinsens1.5 ipinflag1.5 int 6 7 0033h inten1.6 intpri1.6 intsrc1.6 uart1 tx empty uart1 rx available uart1 rx overrun uart1 timer ov p3.6 ipintinv1.6 ipinsens1.6 ipinflag1.6 int 7 8 003bh inten1.7 intpri1.7 intsrc1.7 timer 1 p3.7 ipintinv1.7 ipinsens1.7 ipinflag1.7 int 8 9 0043h inten2.0 intpri2.0 intsrc2.0 timer 2 p0.0 ipintinv2.0 ipinsens2.0 ipinflag2.0 int 9 10 004bh inten2.1 intpri2.1 intsrc2.1 i2c tx empty i2c rx available i2c rx overrun p0.1 ipintinv2.1 ipinsens2.1 ipinflag2.1 int 10 11 0053h inten2.2 intpri2.2 intsrc2.2 uart0 collision uart1 collision i2c master lost arbitration p0.2 ipintinv2.2 ipinsens2.2 ipinflag2.2 int 11 12 005bh inten2.3 intpri2.3 intsrc2.3 pwc 0 end condition pwc 0 end condition p0.3 ipintinv2.3 ipinsens2.3 ipinflag2.3 int 12 13 0063h inten2.4 intpri2.4 intsrc2.4 pwm3 as timer ov pwm2 as timer ov pwm1 as timer ov pwm0 as timer ov p0.4 ipintinv2.4 ipinsens2.4 ipinflag2.4 int 13 14 006bh inten2.5 intpri2.5 intsrc2.5 pwm7as timer ov pwm6as timer ov pwm5as timer ov pwm4as timer ov p0.5 ipintinv2.5 ipinsens2.5 ipinflag2.5 int 14 15 0073h inten2.6 intpri2.6 intsrc2.6 watchdog as timer ov arithmetic unit ov p0.6 ipintinv2.6 ipinsens2.6 ipinflag2.6 int 15 16 007bh inten2.7 intpri2.7 intsrc2.7 port change 1 p0.7 ipintinv2.7 ipinsens2.7 ipinflag2.7
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 81 of 99 14.1 interrupt enable registers the interrupt enable and the general interrupt enable registers establish the link between the peripheral module/pin interrupt signals and the processor interrupt system. the geninten register controls activation of the global interrupt. on the VRS51L2070, only the least significant bit of the geninten is used. the geninten register is sim ilar to the standard 8051 ea bit. when the geninten bit is set to 1, all the enabled interrupts emanating from t he modules/pins will reach the interrupt controller. t able 147:geninten sfr register - n ame sfr e8 h 7 6 5 4 3 2 1 0 - - - - - - - r/w 0 bit mnemonic description 7:2 unused 1 clrpinint it is recommended to set this bit to 1 before enabling a pin interrupt to avoid receiving an interrupt right after geninten bit is set 0 geninten general interrupt enable 0 = all enabled interrupts are masked (deactivated) 1 = all enabled interrupt can raise an interrupt when a given interrupt bit is set to 1, the corresponding interrupt path is activated. t able 148: i nt e nable 1 register - inten1 (m odules /p in /i nt v ector ) sfr 88 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description t1ien timer 1 interrupt enable p3.7 pin p3.7 pin if interrupt source is set to pin 7 int 7 interrupt vector 7 at address 003bh u1ien uart1 interrupt enable o uart1 tx empty o uart1 rx available o uart1 rx overrun o uart1 baud rate generator as timer overflow p3.6 pin p3.6 pin if interrupt source is set to pin 6 int 6 interrupt vector 6 at address 0033h u0ien uart0 interrupt enable o uart0 tx empty o uart0 rx available o uart0 rx overrun o uart0 baud rate generator as timer overflow p3.5 pin p3.5 pin if interrupt source set to pin 5 int 5 interrupt vector 5 at address 0002bh pchgien0 port change interrupt module 0 enable p3.4 pin p3.4 pin if interrupt source is set to pin 4 int 4 interrupt vector 4 at address 0023h t0ien timer 2 interrupt enable p3.3 pin p3.3 pin if interrupt source is set to pin 3 int 3 interrupt vector 3 at address 001bh spirxovien spi interrupt enable spi rx available spi rx overrun p3.0 p3.0 pin if interrupt source is set to pin 2 int 2 interrupt vector 2 at address 0013h spitxeien spi tx empty interrupt enable p3.3 pin p3.3 pin if interrupt source is set to pin 1 int 1 interrupt vector 0 at address 000bh no module unused p3.2 pin p3.2 pin if interrupt source is set to pin 0 int 0 interrupt vector 0 at address 0003h
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 82 of 99 t able 149: i nt e nable 2 register inten2 (m odules /p in /i nt v ector ) sfr a8 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description pchgien1 port change interrupt module 1 enable p0.7 pin p0.7 pin if interrupt source is set to pin 7 int 15 interrupt vector 8 at address 007bh auwdtien watchdog timer and arithmetic unit interrupt enable o watchdog as timer overflow o arithmetic unit 32-bit overflow p0.6 pin p0.6 pin if interrupt source is set to pin 6 int14 interrupt vector 8 at address 0073h pwmt74ien pwm as timer 7 to 4 overflow interrupt enable o pwm as timer module 7 overflow o pwm as timer module 6 overflow o pwm as timer module 5 overflow o pwm as timer module 4 overflow p0.5 pin p0.5 pin if interrupt source set to pin 5 int 13 interrupt vector 8 at address 006bh pwmt30ien pwm as timer 3 to 0 overflow interrupt enable o pwm as timer module 3 overflow o pwm as timer module 2 overflow o pwm as timer module 1 overflow o pwm as timer module 0 overflow p0.4 pin p0.4 pin if interrupt source is set to pin 4 int 12 interrupt vector 8 at address 0063h pwcien pulse width counter interrupt enable o pwc0 end condition occurred o pwc1 end condition occurred p0.3 pin p0.3 pin if interrupt source set to pin 3 int 11 interrupt vector 11 at address 005bh i2cucolien i2c and uarts interrupts enable o i2c master lost arbitration o uart0 collision interrupt o uart1 collision interrupt p0.2 pin p0.2 pin if interrupt source is set to pin 2 int 10 interrupt vector 10 at address 0053h i2cien i2c interrupts enable o tx empty o rx available o rx overrun p0.1 pin p0.1 pin if interrupt source set to pin 1 int 9 interrupt vector 9 at address 004bh t2ien timer 2 interrupt enable (intscr p0.0 pin p0.0 pin if interrupt source is set to pin 0 int 8 interrupt vector 8 at address 0043h 14.2 interrupt source each one of the 16 interrupt vectors on the VRS51L2070 can be configured to function as either a peripheral module or a pin change interrupt. the selection of the interrupt source is handled by the intsrc1 and the intsrc2 registers. by default, the interrupt source is set to peripheral module. however, setting the intsrc bit to 1 will ?associate? the corresponding interrupt vector to the corresponding pin interrupt. when a given interrupt vector is associated with a module, the corresponding bit of the ipinsensx must be set to 0, so it is level sensitive (reset value). t able 150:i nterrupt s ource 1 register - intsrc1 sfr e4 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 intsrc1.7 interrupt 7 source 0 = timer 1 1 = p3.7 6 intsrc1.6 interrupt 6 source 0 = uart1 1 = p3.6 5 intsrc1.5 interrupt 5 source 0 = uart0 1 = p3.5 4 intsrc1.4 interrupt 4 source 0 = port change 0 1 = p3.4 3 intsrc1.3 interrupt 3 source 0 = timer 0 1 = p3.1 2 intsrc1.2 interrupt 2 source 0 = spi rxav, spi rxov 1 = p3.0 1 intsrc1.1 interrupt 1 source 0 = spi tx empty 1 = p3.3 0 intsrc1.0 interrupt 0 source 0 = - 1 = p3.2
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 83 of 99 t able 151:i nterrupt s ource 2 register - intsrc2 sfr e5 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 intsrc2.7 interrupt 15 source 0 = port change 0 1 = p0.7 6 intsrc2.6 interrupt 14 0 = wdt timer ov, au ov 1 = p0.6 5 intsrc2.5 interrupt 13 source 0 = pwm7:4 timer 1 = p0.5 4 intsrc2.4 interrupt 12 source 0 = pwm3:0 timer ov 1 = p0.4 3 intsrc2.3 interrupt 11 source 0 = pwc0, pwc1 1 = p0.3 2 intsrc2.2 interrupt 10 source 0 = uarts coll, i2c lost arbitration 1 = p0.2 1 intsrc2.1 interrupt 9 source 0 = i2c 1 = p0.1 0 intsrc2.0 interrupt 8 source 0 = timer 2 1 = p0.0 14.3 interrupt priority the intprix registers enable the user to modify the interrupt priority of either the module or the pin interrupts. when the intprix is set to 0, the natural priority of module/pin interrupts prevails. setting the intprix register bit to 1 will set the corresponding module/pin priority to high. if more than two module/pin interrupts are simultaneously set to high priority, the natural priority order will apply: priority will be give to the module/pin interrupts with high priority, over normal priority. t able 152:i nterrupt p riority 1 register - intpri1 sfr e2 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 t1p37pri interrupt 7 priority level (timer 1 / p3.7) 0 = normal priority 1 = high priority 6 u1p36pri interrupt 6 priority level (uart1 / p3.6) 0 = normal priority 1 = high priority 5 u0p35pri interrupt 5 priority level (uart0 / p3.5) 0 = normal priority 1 = high priority 4 pc0p34pri interrupt 4 priority level (port chg 0 / p3.4) 0 = normal priority 1 = high priority 3 t0p31pri interrupt 3 priority level (timer 0 / p3.1) 0 = normal priority 1 = high priority 2 srp30pri interrupt 2 priority level (spi rx / p3.0) 0 = normal priority 1 = high priority 1 stp33pri interrupt 1 priority level (spi tx / p3.3) 0 = normal priority 1 = high priority 0 int0p32pri interrupt 0 priority level (int0 / p3.2) 0 = normal priority 1 = high priority t able 153:i nterrupt p riority 2 register - intpri2 sfr e3 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 pc1p07pri interrupt 15 priority level (port chg 1 / p0.0) 0 = normal priority 1 = high priority 6 aip06pri interrupt 14 priority level (wdt, au / p0.6) 0 = normal priority 1 = high priority 5 pwhp05pri interrupt 13 priority level (pwm7:4 timer / p0.5) 0 = normal priority 1 = high priority 4 pwlp04pri interrupt 12 priority level (pwm3:0 timer / p0.4) 0 = normal priority 1 = high priority 3 pwcp02pri interrupt 11 priority level (pwc0, pwc1 / p0.3) 0 = normal priority 1 = high priority 2 int10p01pri interrupt 10 priority level (uarts coll, i2c lost arbitration / p0.2) 0 = normal priority 1 = high priority 1 i2cp01pri interrupt 9 priority level (i2c / p0.1) 0 = normal priority 1 = high priority 0 t2p00pri interrupt 8 priority level (timer 2 / p0.0) 0 = normal priority 1 = high priority
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 84 of 99 14.4 pin inversion setting t able 154: i mpact of p in i nversion setting on p in i nterrupt s ensitivity pin inversion interrupt condition 0 normal interrupt polarity sensitivity 1 inverted interrupt polarity sensitivity t able 155:i nterrupt p in i nversion 1 register - ipininv1 sfr d6 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 p37iinv interrupt 7 pin polarity 0 = p3.7 1 = p3.7 inverted 6 p36iinv interrupt 6 pin polarity 0 = p3.6 1 = p3.6 inverted 5 p35iinv interrupt 5 pin polarity 0 = p3.5 1 = p3.5 inverted 4 p34iinv interrupt 4 pin polarity 0 = p3.4 1 = p3.4 inverted 3 p31iinv interrupt 3 pin polarity 0 = p3.1 1 = p3.1 inverted 2 p30iinv interrupt 2 pin polarity 0 = p3.0 1 = p3.0 inverted 1 p33iinv interrupt 1 pin polarity 0 = p3.3 1 = p3.3 inverted 0 p32iinv interrupt 0 pin polarity 0 = p3.2 1 = p3.2 inverted t able 156: i nterrupt p in i nversion 2 register - ipininv1 sfr d7 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 p07iinv interrupt 15 pin polarity 0 = p0.7 1 = p0.7 inverted 6 p06iinv interrupt 14 pin polarity 0 = p0.6 1 = p0.6 inverted 5 p05iinv interrupt 13 pin polarity 0 = p0.5 1 = p0.5 inverted 4 p04iinv interrupt 12 pin polarity 0 = p0.4 1 = p0.4 inverted 3 p03iinv interrupt 11 pin polarity 0 = p0.3 1 = p0.3 inverted 2 p02iinv interrupt 10 pin polarity 0 = p0.2 1 = p0.2 inverted 1 p01iinv interrupt 9 pin polarity 0 = p0.1 1 = p0.1 inverted 0 p00iinv interrupt 8 pin polarity 0 = p0.0 1 = p0.0 inverted 14.5 pin interrupt sensitivity setting the pin interrupt can be configured as level sensitive or edge triggered. the pin interrupt sensitivity is set via the ipinsensx and ipininvx registers. the following table summarizes the pin interrupt trigger condition settings for ipinsenx and ipininvx. t able 157:i mpact of p in s ensitivity and p in i nversion setting on p in i nterrupt pin sensitivity pin inversion interrupt condition 0 0 high level on pin 0 1 low level on pin 1 0 rising edge on pin 1 1 falling edge on pin the following tables provide the bit definitions for the ipinsens1 and ipinsens2 registers. it is assumed that the corresponding ipininvx bit is set to 0. if the corresponding ipininvx bit is set to 1, the corresponding interrupt event will be inverted. t able 158:i nterrupt p in s ensitivity 1 register - ipinsens1 sfr e6 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 p37isens interrupt 7 pin sensitivity (ipininv1.7 = 0) 0 = p3.7 high level 1 = p3.7 rising edge 6 p36isens interrupt 6 pin sensitivity (ipininv1.6 = 0) 0 = p3.6 high level 1 = p3.6 rising edge 5 p35isens interrupt 5 pin sensitivity (ipininv1.5 = 0) 0 = p3.5 high level 1 = p3.5 rising edge 4 p34isens interrupt 4 pin sensitivity (ipininv1.4 = 0) 0 = p3.4 high level 1 = p3.4 rising edge 3 p31isens interrupt 3 pin sensitivity (ipininv1.3 = 0) 0 = p3.1 high level 1 = p3.1 rising edge 2 p30isens interrupt 2 pin sensitivity (ipininv1.2 = 0) 0 = p3.0 high level 1 = p3.0 rising edge 1 p33isens interrupt 1 pin sensitivity (ipininv1.1 = 0) 0 = p3.3 high level 1 = p3.3 rising edge 0 p32isens interrupt 0 pin sensitivity (ipininv1.0 = 0) 0 = p3.2 high level 1 = p3.2 rising edge
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 85 of 99 t able 159:i nterrupt p in s ensitivity 2 register - ipinsens2 sfr e7 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 p07isens interrupt 7 pin sensitivity (ipininv2.7 = 0) 0 = p0.7 high level 1 = p0.7 rising edge 6 p06isens interrupt 6 pin sensitivity (ipininv2.6 = 0) 0 = p0.6 high level 1 = p0.6 rising edge 5 p05isens interrupt 5 pin sensitivity (ipininv2.5 = 0) 0 = p0.5 high level 1 = p0.5 rising edge 4 p04isens interrupt 4 pin sensitivity (ipininv2.4 = 0) 0 = p0.4 high level 1 = p0.4 rising edge 3 p03isens interrupt 3 pin sensitivity (ipininv2.3 = 0) 0 = p0.3 high level 1 = p0.3 rising edge 2 p02isens interrupt 2 pin sensitivity (ipininv2.2 = 0) 0 = p0.2 high level 1 = p0.2 rising edge 1 p01isens interrupt 1 pin sensitivity (ipininv2.1 = 0) 0 = p0.1 high level 1 = p0.1 rising edge 0 p00isens interrupt 0 pin sensitivity (ipininv2.0 = 0) 0 = p0.0 high level 1 = p0.0 rising edge 14.6 interrupt pin flags for each pin interrupt there is an interrupt flag that can be monitored. when the selected interrupt event is detected on a given pin, the corresponding pin interrupt flag is set to 1 by the system. the interrupt pin flags are automatically cleared when the reti (return from interr upt) instruction is executed. they can also be cleared by the software at any time. the pin interrupt flags can be monitored via the software, even if the corresponding pin interrupt is not activated. if all the corresp onding interrupts are routed to modules and all the interrupts are disabled, the ipinflagx registers can be used as general purpose scratchpad registers. however this is not recommended. t able 160:i nterrupt p in f lag 1 register - ipinflag1 sfr b8 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 p37if interrupt 7 pin flag set to 1 if p3.7 pin interrupt occurs 6 p36if interrupt 6 pin flag set to 1 if p3.6 pin interrupt occurs 5 p35if interrupt 5 pin flag set to 1 if p3.5 pin interrupt occurs 4 p34if interrupt 4 pin flag set to 1 if p3.4 pin interrupt occurs 3 p31if interrupt 3 pin flag set to 1 if p3.1 pin interrupt occurs 2 p30if interrupt 2 pin flag set to 1 if p3.0 pin interrupt occurs 1 p33if interrupt 1 pin flag set to 1 if p3.3 pin interrupt occurs 0 p32if interrupt 0 pin flag set to 1 if p3.2 pin interrupt occurs t able 161:i nterrupt p in f lag 2 register - ipinflag2 sfr d8 h 7 6 5 4 3 2 1 0 r/w r/w r/w r/w r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7 p07if interrupt 15 pin flag set to 1 if p0.7 pin interrupt occurs 6 p06if interrupt 14 pin flag set to 1 if p0.6 pin interrupt occurs 5 p05if interrupt 13 pin flag set to 1 if p0.5 pin interrupt occurs 4 p04if interrupt 12 pin flag set to 1 if p0.4 pin interrupt occurs 3 p03if interrupt 11 pin flag set to 1 if p0.3 pin interrupt occurs 2 p02if interrupt 10 pin flag set to 1 if p0.2 pin interrupt occurs 1 p01if interrupt 9 pin flag set to 1 if p0.1 pin interrupt occurs 0 p00if interrupt 8 pin flag set to 1 if p0.0 pin interrupt occurs
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 86 of 99 15 VRS51L2070 jtag interface the VRS51L2070 includes a jtag interface that enables programming of the on-board flash as well as code debugging. in order to free up as many i/os as possible, the jtag interface pins are shared with regular i/o pins that can be used as general i/os when the jtag interface is not being used. the jtag interface is mapped into the following pins: t able 162: jtag i nterface p in m apping jtag pin function corresponding pin tdi jtag data input p4.3 tdo jtag data output p4.2 cm0 chip mode 0 ale tms test mode select p4.1 tck jtag clock p2.7 activation of the jtag interface is controlled by the cm0/ale pin. the cm0/ale pin includes an internal pull-up resistor. when the cm0 pin is held at a logic low and a reset is performed, the jtag interface is activated. 15.1 impact of jtag interface activation when the jtag interface is connected, it has the following impact on the VRS51L2070 operation: ? the pwm 7 output is deactivated. the pwm7 module can still be active. ? the p2.7, p4.3, p4.2, p4.1 i/o pins are deactivated. ? the ale pin is reserved for the jtag interface. to efficiently debug code accessing the external sram memory, place a 1k ohms resistor in the path of cm0 to the jtag interface module. 15.2 VRS51L2070 debugger the VRS51L2070 includes advanced debugging features that enable real-tim e, in-circuit debugging and emulation via the jtag interface. when the VRS51L2070 debugger is activated, the upper 1024 bytes of the flash memory are not available for user program. the VRS51L2070 debugger is intended to be used in conjunction with the versa ware jtag software, developed by ramtron. this software provides an easy-to-use interface for device programming and in- circuit debugging. for more information on the VRS51L2070 debugger?s features and use, please consult the versa ware jtag user guide. 16 flash programming interface (fpi) the fpi module allows the processor to perform in- application management of the flash memory content. the following operations are supported by the fpi module : ? mass erase ? page erase ? byte write six sfr registers are associated with the fpi module operation, as shown in the table below: t able 163: f lash programming interface registers sfr name function reset value e9h fpiconfig configures the fpi operations 34h eah fpiaddrl address for operation (lower byte) 00h ebh fpiaddrh address for operation (upper byte) 00h ech fpidatal data to write 00h edh fpidatah upper byte of data to write 00h eeh fpiclkspd clock speed during fpi operations 00h the fpi module is activated by setting bit 0 of the periphen2 register. there are two ways to perform read and write operations to the flash using the fpi module: the standard 8-bit mode, which writes 1 byte at a time and an extended 16-bit mode, which writes 2 bytes at a time (1 word), effectively doubling the writing speed. in addition, whenever a write or read is performed, the address is incremented automatically by the fpi module, saving processor cycles.
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 87 of 99 16.1 fpi configuration register flash operations are activated via the fpi configuration register. the following table describes the fpi configuration register: t able 164: fpi c onfiguration r egister - fpiconfig sfr e9 h 7 6 5 4 3 2 1 0 r r r r r/w r/w r/w r/w 0 0 1 1 0 1 0 0 bit mnemonic description 7:6 fpilock[1:0] these bits indicate the stage of the unlock operation: 00 : iap protection on (no unlock steps done) 01 : iap first unlock step done: fpi_data_lo received 0xaa 10 : iap protection off: second step done fpi_data_lo received 0x55) 11 : disables write/erase operations until the next system reset. this occurs if a wrong sequence is used. 5 fpiidle always = 1 indicates that the fpi is idle 4 fpirdy indicates that the fpi is idle in all modes except "write byte" mode, in which the double buffer is ready for a new value 3 reserved keep this bit at 0 2 fpi8bit fpi operating mode 0 = fpi operates in 16-bit mode 1 = fpi operates in 8-bit mode 0 fpitask[1:0] fpitask operation 00: read mode 01: mass erase 10: page erase 11: write byte (writing to fpidatal start byte write operation ) note that actions are only started if fpiready is high, otherwise the action is cancelled 16.2 fpi flash address and data registers the fpiaddrh and fpiaddrl registers are used to specify the address at whic h the iap function will be performed. t able 165: fpi a ddress h igh fpiaddrh sfr eb h 7 6 5 4 3 2 1 0 r/w, reset = 0x00 fpiaddr[15:8] the fpiaddrh register contains the msb of the destination address. for page erase operations, it contains the page number where page erase operations are performed. t able 166:fpi a ddress l ow -fpiaddrl sfr ea h 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 r/w fpiaddr[7:0] the fpiaddrl register contains the lsb of the destination address where the operation is performed. for page erase it must contain the value 0x00. the fpidatah and fpidatal sfr registers contain the data byte required to perform the fpi function. t able 167: fpi d ata h igh - fpidatah sfr ed h 7 6 5 4 3 2 1 0 r/w, reset = 0x00 fpidata[15:8] when read: msb of last wo rd read[15:8] from flash when write: byte[15:8] to write in flash t able 168:fpi data l ow - fpidatal sfr e ch 7 6 5 4 3 2 1 0 r/w, reset = 0x00 fpidata[7:0] read: last read byte[7:0] from flash writing to this byte in 'fpi write mode' triggers the fpi state machine to start the write action. 16.3 fpi clock speed control register the fpi clock speed control register sets the fpi module to an optimal speed based on the speed of the system clock. t able 169:fpi c lock s peed c ontrol r egister - fpiclkspd sfr ee h 7 6 5 4 3 2 1 0 r r r r r/w r/w r/w r/w 0 0 0 0 0 0 0 0 bit mnemonic description 7:4 unused 3:0 fpiclkspd [3:0] specifies speed of the system clock entering the fpi module frequency range: 0000 : 20mhz to 40 mhz 0001 : 10mhz to 20 mhz 0010 : 5mhz to 10 mhz 0011 : 2.5mhz to 5 mhz 0100 : 1.25mhz to 2.5 mhz 0101 : 625khz to 1.25 mhz 0110 : 312.5khz to 625 khz 0111 : 156.25khz to 312.5 khz 1000 : 78.12khz to 156.25 khz 1001 : 39.06khz to 78.125 khz 1010 : 19.53khz to 39.0625 khz others : 9.76khz to 19.53125 khz use the settings found in the following table when using the fpi at a speed other than the nominal speed of the internal oscillator.
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 88 of 99 t able 170: s etting the fpiclkspd register range value minimum maximum 0 (default) 20.000 mhz 40.000 mhz 1 10.000 mhz 20.000 mhz 2 5.000 mhz 10.000 mhz 3 2.500 mhz 5.000 mhz 4 1.250 mhz 2.500 mhz 5 625.000 khz 1.250 mhz 6 312.500 khz 625.000 khz 7 156.250 khz 312.500 khz 8 78.125 khz 156.250 khz 9 39.063 khz 78.125 khz 10 19.531 khz 39.063 khz other 9.766 khz 19.531 khz the fpiclkspd register must be set to the corresponding system clock speed for proper operation of the fpi module. for ex ample, a 20.0 mhz clock requires fpiclkspd to be set to 1, while a 20.1 mhz clock requires fpiclkspd to be set to 0. if fpiclkspd is set in correctly, the flash write operation may not process correctly, causing data corruption. 16.4 using the fpi interface 16.4.1 write protection the VRS51L2070 provides a safety mechanism to prevent accidental writing or erasing of the flash. the following sequence must be written to the fpidatal register to unlock the VRS51L2070 each time a write is performed. fpidatal ? aah fpidatal ? 55h not performing the above sequence will lock the fpi module until a reset of the VRS51L2070 is performed. bit 7 and 6 of the fpiconfig provide the status of the fpi write protection circuitry. 16.4.2 fpiidle this bit indicates whether the previous action is complete and the fpi is idle. the fpiidle bit must be checked before performing any fpi operation, to ensure that the module is ready. 16.4.3 fpirdy when writing a stream of bytes or words, this bit indicates whether the fpi is ready for the next write. note that aah then 55h must first be written in order to unlock the fpi module. 16.4.4 fpi8bit the fpi8bit bit of the fp iconfig register defines whether the fpi module read and write operations will be performed in 8 or 16-bit format. when the fpi8bit bit is set to 1, the fpi module will operate in 8-bit mode. the 16-bit address of the flash memory, where the fpi operation will be performed, is defined by the value of the fpiaddrh and fpiaddrl registers. when the fpi module is used to write data into the flash memory, the fpidatal register holds the value of the data to be written. when the fpi module is used to read the flash, the read value is returned via the fpidatal register. when the fpi8bit bit is cleared, the fpi module will operate in 16-bit mode. in this case, the address range is defined by a 15-bit address [0000 ? 7fff] and must be written into the fpiaddrh and fpiaddrl registers. when a 16-bit fpi write operation is performed, the 16-bit data must be stored in the fpidatah and fpidatal registers. when a flash memory read operation is performed, the 16-bit data will be returned to the fpidatah and fpidatal registers. 16.5 performing a read there are three ways to read directly from the VRS51L2070 flash memory: 1. use the movc instruction 2. use the fpi in 8-bit mode 3. use the fpi in 16-bit mode it may be preferable to use the fpi over the movc instruction, because some co mpilers will optimize code that repeatedly checks the flash. to perform a read, perform the following steps: o make sure the fpi module is enabled o set fpiaddrh and fpiaddrl to the appropriate address (see section 1.1.4) o write 00000x00 to the fpiconfig register, where x = 1 if reading 8 bits, and x = 0 if reading 16 bits o loop until fpi_idle is raised o get the results from fpidatah and fpidatal if in 16-bit mode, or from fpidatal if in 8-bit mode
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 89 of 99 16.5.1 fpi flash read in 8-bit mode example the following code sequence follows the above algorithm to read address abcdh in 8-bit mode: orl perhiphen2, #1 ; enable fpi mov fpiaddrh, #0abh ; move in upper address mov fpiaddrl, #0cdh ; move in lower address mov fpiconfig, #004h ; trigge r the read in 8-bit mode wait: mov a, fpiconfig ; get the fpi status jnb acc.7, wait ; jump if not ready ; the read is now done. the result in fpidatal 16.5.2 fpi flash read in 16-bit mode example the following code sequence will read 16 bits from address abcd: #include <VRS51L2070.h> unsigned char ucupper; unsigned char uclower; void readfpi(int address) { unsigned char result; periphen2 |= 1; /* enable fpi */ fpiaddrh = (unsigned char) (address >> 8); /* upper address */ fpiaddrl = (unsigned char) address; /* lo wer address ? automatically truncates */ fpiconfig = 0; /* trigger the read */ do { result = fpiconfig & 0x20; /* check for the fpi_idle bit */ } while(!result) ucupper = fpidatah; uclower = fpidatal; } void main() { /*** some code***/ readfpi(0x55e6); /* this is address abcd converted to 16 bit addressing */ /*** some code***/ while(1); } 16.6 erasing flash 16.6.1 page erase when storing nonvolatile data, it is necessary to erase the flash before writing to it. programming is done by byte or word boundary, while erase is done by page boundary. a page is a contiguous block of 512 addresses. page numbers can be calculated from the following formula: page = address / 512 page 0 contains all the addresses from 0000h to 01ffh, page 1 contains all the addresses from 0200h to 03ffh and so on. there are 128 pages of flash on the VRS51L2070 (64kb flash). to erase a page, follow these steps: 1. ensure that the fpi module is enabled 2. write aah to the fpidatal register 3. write 55h to the fpidatal register 4. write 0 to the fpiaddrl register 5. write the page number to the fpiaddrh register 6. write 2 to the fpiconfig register 7. wait for fpi_idle to go high 16.6.2 fpi page erase example this code sequence will erase page 64: orl perhiphen2, #1 ; enable fpi mov fpidatal, #0aah ; unlock 1 mov fpidatal, #055h ; unlock 2 mov fpiaddrl, #0 ; move in 0 mov fpiaddrh, #64 ; move in page number mov fpiconfig, #2 ; trigger the page erase wait: mov a, fpiconfig ; get the fpi status jnb acc.7, wait ; jump if not ready ; the page is now erased 16.6.3 mass erase it is possible to completely erase the flash memory from within a program. to do so, the following steps must be performed: 1. make sure that the fpi module is enabled 2. write aah to the fpidatal register 3. write 55h to the fpidatal register 4. write 1 to the fpiconfig register 5. if still possible, wait for fpi_idle to go to 1 the flash is now completely erased. warning: at this point, the flash should be totally erased. if running from external memory, make sure it is copied back to its locations in flash with write commands. step 5 can only be performed if executing code from external sram. 16.7 writing to the flash there are two methods to write to the flash: o 8-bit double buffered o 16-bit double buffered depending on the complexity and the amount of flash to be written, one mode may be more efficient than the other: 8-bit mode is more suited to programming a few bytes of data, while 16-bit mode is more suited to memory dumping. writing the flash in 8-bit mode 1. make sure the fpi module is enabled 2. write 7 to the fpiconfig register 3. set fpiaddrh and fpiaddrl to the appropriate addresses
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 90 of 99 4. write aah to the fpidatal register 5. write 55h to the fpidatal register 6. write data to the fpidatal register (this triggers the operation) 7. if complete, wait for fpi_idle to go high. if there are more bytes to be written at a different address, return to step 3. if the next address is contiguous, go to step 4 instead. note that the addr ess the data is written to will be automatically incremented for the next byte. as such, the address only needs to be written once per data stream (assuming that a contiguous block is written), as shown in the following example. 16.7.1 fpi flash write in 8-bit mode example //********************************************* //* fpi flash write 8bit mode example * //********************************************* #include <VRS51L2070.h> /* this function uses the fpi module to write a null terminated string to flash */ void copy_to_flash(int address, char *str) { unsigned char ready; /* is the fpi idle? */ periphen2 |= 1; /* enable fpi */ /* upper address */ fpiadrh = (unsigned char) (address >> 8); /* lower address - automatically truncates */ fpiadrl = (unsigned char) address; fpiconfig = 7; /* trigger the write in 8 bit mode */ while(*str) /* while not null */ { fpidatal = 0xaa; /* 1st step unlock */ fpidatal = 0x55; /* 2nd step unlock */ fpidatal = (unsigned char)(*str); /* wait for the buffer to be ready */ /* the operation is not finished, check for fpi_ready */ do { ready = fpiconfig & 0x10; }while(!ready); str++; } /* null character encountered, write an additional 0 to memory */ fpidatal = 0xaa; /* 1st step unlock */ fpidatal = 0x55; /* 2nd step unlock */ fpidatal = 0; /* end in null - this avoids having to pass the string length */ /* the operation is finished, check for fpi_idle instead of fpi_ready */ do { ready = fpiconfig & 0x20; }while(!ready); return; } void main(void) { /*** code ***/ copy_to_flash(0x3000, "ramtron inc"); copy_to_flash(0x4000, "microsystems connecting two worlds"); /*** code ***/ while(1); } 16.7.2 writing to the flash in 16-bit mode follow the steps below to write in 16-bit mode: 1. make sure the fpi module is enabled 2. write 3 to the fpiconfig register 3. set fpiaddrh and fpiaddrl to the appropriate addresses (remember to convert to 16-bit addressing) 4. write aah to the fpidatal register 5. write 55h to the fpidatal register 6. write data to the fpidatal register (this triggers the operation) 7. if complete, wait for fpi_idle to go high. if there are more bytes to be written at a different address, return to step 3. if the next address is contiguous, go to step iv instead note that the add ress the data is wr itten to will be automatically incremented for the next byte as such, the address only needs to be set once per data stream (assuming a contiguous region is written), as shown in the following example. 16.7.3 fpi flash write in 16-bit mode example this routine copies 512 bytes (1 page) of external sram to the flash memory at address e000h + xram. the r0 and r1 registers contain the starting address of the page to copy. //********************************************* //* fpi flash write 16-bit mode example * //********************************************* write_page: push dph0 ;push the data pointer push dpl0 push acc ;push the var. to be used push b mov acc, r2 push acc mov dph0, r1 ;load the data pointer mov dpl0, r0 mov r2, #255 ;loop counter (511 bytes) orl perhiphen2, #1 ;enable fpi module mov fpiconfig, #3 ;enable writing in 16 bit ;mode ; set the address must be 16 bits (address / 2) clr c ;clear the carry flag mov a, r1 rrc a ;check if there will be a carry clr a ;does not affect carry bit rrc a ;sets a to 80h if r1 was odd, or ;keeps it 0
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 91 of 99 mov fpiadrl, a ;set lower address mov a, r1 rr a ;divide address by 2 add a, #7 ;adds e000h to the address ;(e000 / 2 = 7000) mov fpiadrh, a ; set upper address write_page_loop: mov fpidatal, #0aah ;unlock step 1 mov fpidatal, #055h ;unlock step 2 movx a, @dptr mov b, a inc dptr ;next byte movx a, @dptr inc dptr ;next byte mov fpidatah, a ;set the upper value mov fpidatal, b ;set the lower value ;and start the write write_page_loop_wait: mov a, fpiconfig ;check to see if the ;buffer is ready ;jump if fpi_ready is not high jnb acc.4 ,write_page_loop_wait djnz r2 ,write_page_loop ;now write the last word (byte 511 and 512) mov fpidatal, #0aah ;unlock step 1 mov fpidatal, #055h ;unlock step 2 movx a, @dptr mov b, a inc dptr ;next byte movx a, @dptr inc dptr ;next byte ;(not necessary) mov fpidatah, a ;set the upper value mov fpidatal, b ;set the lower value ;and start the write write_page_last_wait: mov a, fpiconfig ;check to see if the ;buffer is ready jump if fpi_idle is not high (last word) jnb acc.5 , write_page_loop_wait ;restore variables used pop b pop acc mov r3, acc pop acc pop dpl0 pop dph0 ret ;return to caller 16.8 tips on using the fpi interface the following tips can be used to get the most out of the iap features on the VRS51L2070. ? shorter programming time can be achieved if the fpi flash write rout ines are run from the 4kb external memory sram, as the circuitry that reads instructions from the flash does not interfere with the fpi module. ? the flash must be erased before reprogramming, and the same value should not be written more than once to the same flash address, unless an erase cycle is performed in between writes. ? to maximize the endurance of the VRS51L2070 flash memory, fpi flash page erase operations should be done sparingly. ? the fpi mass erase f unction will erase the entire VRS51L2070 flash memory, including code already programmed. ? iap can be performed even if the flash protection is enabled. it is the responsibility of the programmer not to reveal the flash information of a secured device via the iap. ? when write operations are performed at the boundaries of two contiguous blocks of memory, the address will automatically increment to the next byte/word after a write cycle. this can save processor cycles. ? the fpi read can be used to perform flash memory reads, however using the movc instruction is more efficient. ? make sure that the location being written to does not interfere with the program running in the flash.
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 92 of 99 17 crystal consideration by default, the VRS51L2070 derives its clock from its internal oscillator. it is also possible to use external crystal for the VRS51L2070 clock source. the crystal connected to the VRS51L2070 oscillator input should be parallel cut type, operating in fundamental mode. the addition of 15 to 20pf load capacitors is recommended. see the following figure for a connection diagram. note: oscillator circuits may differ with different crystals or ceramic resonators in higher oscillation frequency. crystals or ceramic resonator characteristics may also vary from one manufacturer to another. the user should review the technical literature associated with specific crys tal or ceramic resonator s or contact the manufacturer to select the appropriate values for the external components. f igure 36: VRS51L2070 e xternal c rystal o scillator configuration VRS51L2070 xtal1 xtal2 xtal c1 c2
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 93 of 99 18 operating conditions 18.1 absolute maximum ratings parameter min. max. unit notes supply voltage input (vdd ? vss) 3.1 3.6 v engineering samples i/o input voltage all except p4.6 & p4.7 -0.5v 5.5v v preliminary i/o input voltage p4.6 & p4.7 only vdd-0.5 vdd+0.5 v preliminary maximum i/o current (sink/source) qfp64 package 90 100ma preliminary 18.2 nominal operating conditions t able 171: o perating c onditions symbol description min. typ. max. unit remarks ta operating temperature -40 25 +85 oc ts storage temperature -55 25 155 oc vcc5 supply voltage 3.1 3.3 3.6 v fextosc 40 ext. oscillator frequenc y 1.0 - 40 mhz for 3.3v application 18.3 dc characteristics vcc = 3.3v, temp = 25oc, no load on i/os t able 172: dc c haracteristics symbol parameter valid min. typ max. unit test conditions vil1 input low voltage p o r t 0 ,1,2,3,4,5,6 -0.35 0.80 v vcc=3.3v vil2 input low voltage reset, xt al1 -0.35 0.80 v vcc=3.3v vih1 input high voltage p o r t 0,1,2,3,4,5,6 2.0 5.5 v vcc=3.3v vi h2 input high voltage res, xtal1 2.0 5.5 v vcc=3.3v vol1 output low voltage port 0 , 1,2,3,4,5,6,ale 0.2 v iol = rated i/o max current voh2 output high voltage port 0 , 1,2,3,4,5,6,ale vcc ? 0.3v v max rated i/o current ili input leakage current p o r t 0 , 1,2,3,4 40 ua r res reset equivalent pull-up resistance res tbd kohm c - 10 pin capacitance 10 pf freq=1 mhz, ta=25 c 17*ma 27* ma active mode, 40mhz (int. oscillator) 7.5* ma active mode, 10mhz (int. oscillator) 5.5 ma active mode 4 mhz (ext. crystal) 3.6* 11* ma idle mode, oscillator running 40mhz ic c power supply current vdd 1.1* ma osc stop mode *preliminary
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 94 of 99 18.4 VRS51L2070 timings parameters t able 173: ac c haracteristics variable fosc symbol parameter min. typ max. unit ale pulse width ns address valid to ale low ns address hold after ale low ns ale low to valid instruction in ns ale low to #psen low ns #psen pulse width ns #psen low to valid instruction in ns instruction hold after #psen ns instruction float after #psen ns address to valid instruction in ns #psen low to address float ns #rd pulse width ns #wr pulse width ns #rd low to valid data in ns data hold after #rd ns data float after #rd ns ale low to valid data in ns address to valid data in ns ale low to #wr high or #rd low ns address valid to #wr or #rd low ns data valid to #wr high ns data valid to #wr transition ns data hold after #wr ns #rd low to address float ns #w r or #rd high to ale high ns clock fall time ns clock low time ns clock rise time ns clock high time ns clock period ns
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 95 of 99 18.5 data memory read cycle timing ? multiplexed mode the following diagram shows the timing of a mu ltiplexed external data memory read cycle. f igure 37: d ata m emory r ead c ycle t iming p2 a[14:8] p 0 a[7:0]/d[7:0] clk ale rd a[7:0] multiplexed read data 18.6 data memory write cycl e timing ? multiplexed mode the following diagram shows the timing of a mult iplexed external data memory write cycle. f igure 38: d ata m emory w rite c ycle t iming p2 a[14:8] p0 a[7:0]/d[7:0] ale wr clk a[7:0] d[7:0] multiplexed write
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 96 of 99 18.7 data memory read cycle timing ? non-multiplexed mode the following diagram shows the timing of a non- multiplexed external data memory read cycle. f igure 39: d ata m emory r ead c ycle t iming p2:p 6 a[14:0] p 0 d[7:0] rd clk non- multiplexed read data ce-
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 97 of 99 18.8 timing requirement of the external clock the following diagram shows the timing of an external clock driving the VRS51L2070 input. f igure 40: t iming r equirement of e xternal c lock (vss= 0.0v is assumed ) clkper clkhigh clkrt clkft clklow vdd - 0.5v 0.5v t able 174: e xternal c lock t iming requirements variable fosc symbol parameter min. typ max. unit clkper ext. clock period 25 ns clklow ext. clock low duration ns clkhigh ext. clock high duration ns clkft ext. clock fall time ns clkrt ext. clock rise time ns .
VRS51L2070 ___________________ __________________ __________________ _______________ _______________ ___________ www.ramtron.com page 98 of 99 19 VRS51L2070 package 19.1 VRS51L2070 qfp-64 package f igure 41: VRS51L2070 qfp-64 p ackage drawings a2 a1 c e b 17 32 18 19 20 21 22 23 24 25 26 27 28 29 30 31 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 e1 d1 VRS51L2070 qfp-64 t able 175: d imensions of qpf-64 p ackage symbol description qfp-64 d1 body size 14 e1 body size 14 a1 stand-off 0.1 a2 body thickness 1.4 l1 lead length 1 b lead width 0.35 c l/c thickness 0.127 e lead pitch 0.8
VRS51L2070 _ __________________ __________________ _______________ ______________ _______________ ______________ _ www.ramtron.com page 99 of 99 20 ordering information 20.1 device number structure vrs51 l 2070 - 40 ? x x x temperature range blank = industrial (-40c to +85c) package options r = 64-pin quad flat pack (qfp-64) operating frequency 40: 40mhz oscillator frequency product number operating voltage l= 3.1v ? 3.6volts green blank = no green g = green (lead-free) 2070 ? 64-pin package 20.2 VRS51L2070 orde ring options t able 176: VRS51L2070 p art numbering device number flash size sram size package option voltage temperature frequency VRS51L2070-40-qg 64kb 4352 qfp-64 3.1v to 3.6v -40c to +85c 40mhz errata: engineering samples of the VRS51L2070 have an operating voltage of 3.1 to 3.6v instead of 3.0 to 3.6v readback of the content in the thx/tlx and rcapxh/rc apxl timer registers will return to 0x00 unless the corresponding timer is running or, for the timers 0 and 1, the timer gating bit is set. disclaimers right to make change - ramtron reserves the right to make changes to its produ cts - including circuitry, soft ware and services - without notice at any time. customers should obtain the most cu rrent and relevant informati on before placing orders. use in applications - ramtron assumes no responsibility or liability for the us e of any of its products, and conveys no license or title under any patent, copyright or mask work right to these products and makes no representations or warranties that these products are free from patent, copyright or mask work right infringement unless otherwise specifi ed. customers are responsible for product d esign and applications using ramtron parts. ramtron assumes no liability for applications assistance or customer product design. life support ? ramtron products are not designed for use in life suppor t systems or devices. ramtr on customers using or selling ramtron?s products for use in such applications do so at t heir own risk and agree to fully indemnify ramtron for any damages re sulting from such applications. i2c is a trademark of koninklijke philips electronics nv.


▲Up To Search▲   

 
Price & Availability of VRS51L2070

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X